Support Forums : Complicated Page Jumping Logic Question

We encourage an open exchange of information. Ask your questions or make suggestions. We are here to help, but we also encourage all of you to help one another.
Click on the Subscribe Flag to be notified by email of replies to your post.
Current User: Guest Login Register
Please consider registering

Complicated Page Jumping Logic Question

Add a New Topic Reply to Post
UserPost

12:23
August 19, 2008


steinhardt.webmaster

Member

posts 21

Hallo, all.  I have a rather complicated bit of page logic that I'm trying to figure out.  It relates to the survey located at:
http://app.sgizmo.com/surveybuilder/survey_editor.php?id=62271

(Note, I'm still working on correcting some of the input of that survey, so it may not show the best examples).

Here's the gist of what I'm trying to do:

  • I have a series of Matrix ranking questions.  There are several rows for each, but the columns for all of them are a ranking of 1-5.
  • I want to change which page they go to next based on the FIRST ranking they give that does NOT EQUAL 1.
    • So a response of 1,1,5,2,3,1,4 would take you to “page 5″
    • A response of 2,1,1,1,1,1,1 would take you to “page 2″
    • A response of 1,1,1,1,1,1, would take you to “page 1″
    • A response of 1,1,1,1,1,3 would take you to “page 3″

I imagine there must be a way to do this with advanced scripting controls, but I'm at a bit of a loss as to where to begin. 

Do you think someone could get me started on how to create an array of responses from matrix questions?  I think if I can get that far, I'll be good to go.

4:58
August 19, 2008


Mario

Moderator

Boulder, CO

posts 543

With more than one matrix on the page, you would be making the decision based upon the first answer on any matrix that is not a 1, or what would you do if you evaluated it per matrix and there are mutliple matrices on the page?


You are correct that this would be the advanced scripting controls, and you would be looking through the question sku's for the matrix. For instance, in the first matrix, your rows are question id's 88-91. You can specify these in an array, then write a foreach loop to go through each one and check if the response is 1, if != 1 (not equal to 1), the jump to the value that is returned (2-5) and then break; out of the foreach loop.

Hope that gets you started… it's a bit of an undertaking, so I feel obliged to mention our Professional Services, to build it the first time and give you something to work off of.

5:27
August 27, 2008


steinhardt.webmaster

Member

posts 21

Well, after a lot of  banging my hands against the keyboard (and my head against the desk) I figured out how to do this using scripting control.  I figured I would go ahead and post my solution here.

The first key, which is mentioned elsewhere in the forum, is to understand that each row in a matrix question has ITS OWN question sku.  As near as I can tell, the only way to see the sku is to “view source” of the survey and pull it right from the code.  In my survey, I was able to identify it like so:

    <tr id=”sgq10_row_1″ class=”sg_TR_Alt”  >

        <td class=”sg_TD1″  scope=”row”  width=”150″  style=”width:150px !important” >The Factor Game</td>
            <td class=”sg_TDX sg_TD2″  style=”width:100px !important”  align=”center” ><input class=”sg_Radio” type=”radio”  name=”Q_11″  id=”Q_11O0″  title=”Use without modification”  value=”O0″ /></td>
            <td class=”sg_TDX sg_TD3″  style=”width:100px !important”  align=”center” ><input class=”sg_Radio” type=”radio”  name=”Q_11″  id=”Q_11O1″  title=”Use with adaptation”  value=”O1″ /></td>
            <td class=”sg_TDX sg_TD4″  style=”width:100px !important”  align=”center” ><input class=”sg_Radio” type=”radio”  name=”Q_11″  id=”Q_11O2″  title=”Use as a one of many resources”  value=”O2″ /></td>
            <td class=”sg_TDX sg_TD5″  style=”width:100px !important”  align=”center” ><input class=”sg_Radio” type=”radio”  name=”Q_11″  id=”Q_11O3″  title=”Replace”  value=”O3″ /></td>
            <td class=”sg_TDX sg_TD6″  style=”width:100px !important”  align=”center” ><input class=”sg_Radio” type=”radio”  name=”Q_11″  id=”Q_11O4″  title=”Does not use”  value=”O4″ /></td></tr>
    <tr id=”sgq10_row_2″ class=”sg_TR”  >
        <td class=”sg_TD1″  scope=”row”  width=”150″  style=”width:150px !important” >The Product Game</td>

            <td class=”sg_TDX sg_TD2″  style=”width:100px !important”  align=”center” ><input class=”sg_Radio” type=”radio”  name=”Q_12″  id=”Q_12O0″  title=”Use without modification”  value=”O0″ /></td>
            <td class=”sg_TDX sg_TD3″  style=”width:100px !important”  align=”center” ><input class=”sg_Radio” type=”radio”  name=”Q_12″  id=”Q_12O1″  title=”Use with adaptation”  value=”O1″ /></td>
            <td class=”sg_TDX sg_TD4″  style=”width:100px !important”  align=”center” ><input class=”sg_Radio” type=”radio”  name=”Q_12″  id=”Q_12O2″  title=”Use as a one of many resources”  value=”O2″ /></td>
            <td class=”sg_TDX sg_TD5″  style=”width:100px !important”  align=”center” ><input class=”sg_Radio” type=”radio”  name=”Q_12″  id=”Q_12O3″  title=”Replace”  value=”O3″ /></td>
            <td class=”sg_TDX sg_TD6″  style=”width:100px !important”  align=”center” ><input class=”sg_Radio” type=”radio”  name=”Q_12″  id=”Q_12O4″  title=”Does not use”  value=”O4″ /></td></tr>

(So the code above shows two rows from a matrix question with the sku of 11 and 12.  The sku for the question itself is 10.)

The other key was realizing the Page Jumping in the current version of SurveyGizmo is a little bit broken… Particularly when you reorder questions or create them out of order.  Rather than use simple page jumping, it is MUCH MORE RELIABLE to use Show/Hide logic.  The difference between “jumping” to three pages later and “hiding” the pages between here and there took me a bit to get over.  But using this method makes scripting a TON easier.

Once I was armed with these two key pieces of data, I was ready to go.  I created an array of the matrix responses. Then I looped through each of them to check to see if the response was != to the default answer.  If it was not, I recorded that variable in a hidden tracking value and used it to determine which pages were shown and which were hidden.

The code I used is pasted below for others' use and future reference. Any critique is welcome (especially a way to just create the arrays via looping instead of adding them all manually).  Hope this helps out others in the future!

%%destination = 'blank';

%%skustocheck[] = 295;
%%skustocheck[] = 296;
%%skustocheck[] = 297;
%%skustocheck[] = 298;
%%skustocheck[] = 300;
%%skustocheck[] = 301;
%%skustocheck[] = 302;
%%skustocheck[] = 303;
%%skustocheck[] = 305;
%%skustocheck[] = 306;
%%skustocheck[] = 307;
%%skustocheck[] = 309;
%%skustocheck[] = 310;
%%skustocheck[] = 311;
%%skustocheck[] = 312;
%%skustocheck[] = 314;
%%skustocheck[] = 315;
%%skustocheck[] = 316;
%%skustocheck[] = 317;
%%skustocheck[] = 318;
%%skustocheck[] = 320;
%%skustocheck[] = 321;
%%skustocheck[] = 322;
%%skustocheck[] = 323;
%%skustocheck[] = 325;
%%skustocheck[] = 326;
%%skustocheck[] = 327;
%%skustocheck[] = 328;
%%skustocheck[] = 329;

foreach(%%skustocheck as %%sku)
{
  if (%%destination == 'blank')
    {    
      %%reportvalue = sgapiGetValue(%%sku);
      if (%%reportvalue != 'Use without modification')
      {
        %%destination = %%reportvalue;
        %%yourtitle = sgapiGetTitle(%%sku,”English”);
      }
    }
    
}

%%output .= 'You chose <strong>' . %%destination . '</strong> for <strong>';
%%output .= %%yourtitle . '</strong>.  For each lesson in ' .  %%yourtitle . ' ';
%%output .= 'please provide more detail on the next page.  Click the button below to continue.';
sgapiSetValue(76,%%destination);


Add a New Topic Reply to Post


Reply to Topic: Complicated Page Jumping Logic Question

Guest Name (Required):

Guest EMail (Required):

Guest URL (required)

Math Required!
What is the sum of: 2 + 1        (Required)

Topic Reply:


 
© Simple:Press Forum - Version 3.1.4 (Build 357)