Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

"setting" a count so that it doesn't change

Hi all

On version 7.

My respondent is asked to rate a number of teams he/she has selected on a previous page.  Each team's stuff is presented on one page, and the pages are randomised.  I have a piece of perl code at the top of each page letting the respondent know where they are up to (ie Team 1 of 3).  Works really well - as long as they don't hit the back button.  The count continues (ie Team 4 of 3).  Is there any way I can "set" the code so that once the "next" button is clicked, it doesn't change if the respondent chooses to go back and amend stuff?

Here's the code I'm using.  Just set up for two teams at the moment, but there'll be 20 or so.

<table border="1" cellpadding="10" cellspacing="0" width="150" bgcolor="#B5C0D8">
<tr>
  <td> Team [%Begin Unverified Perl

my $count = 1;

if(VALUE("T01Q1_r1") > 0)  { $count = $count + 1;  }
if(VALUE("T02Q1_r1") > 0)  { $count = $count + 1;  }

return $count;

end unverified%] of [%numchecked(Support)%] </td>
</tr>
</table>
asked Oct 27, 2012 by anonymous

3 Answers

0 votes
I used a different technique that works fine using Perl.

I created 3 questions on seperate pages called Team1, Team2 and Team3. I randomised the 3 pages using the randomise pages feature anchoring Team1 (anchor question 1) and Team3 (anchor question 2).

I created a parent list called TeamPageList. It contained 3 codes 1-2-3.

I then created a TeamPage1ConList (for page 1), a TeamPage2ConList (for page 2) and a TeamPage3ConList (for page 3).

On the Team1 page, I inserted "Page [%ListLabel(TeamPage1ConList,1)%] of 3" in Header 1.
On the Team2 page, I inserted "Page [%ListLabel(TeamPage2ConList,1)%] of 3" in Header 1.
On the Team3 page, I inserted "Page [%ListLabel(TeamPage3ConList,1)%] of 3" in Header 1.

Here's the code for each of the constructed lists ...

TeamPage1ConList
Begin Unverified Perl

if ((VALUE("Team2")>0) && (VALUE("Team3")>0))
 {
  ADD("TeamPageList",3);
 }

if ((VALUE("Team2")>0) && (VALUE("Team3")<1))
 {
  ADD("TeamPageList",2);
 }

if ((VALUE("Team2")<1) && (VALUE("Team3")>0))
 {
  ADD("TeamPageList",2);
 }

if ((VALUE("Team2")<1) && (VALUE("Team3")<1))
 {
  ADD("TeamPageList",1);
 }

End Unverified


TeamPage2ConList
Begin Unverified Perl

if ((VALUE("Team1")>0) && (VALUE("Team3")>0))
 {
  ADD("TeamPageList",3);
 }

if ((VALUE("Team1")>0) && (VALUE("Team3")<1))
 {
  ADD("TeamPageList",2);
 }

if ((VALUE("Team1")<1) && (VALUE("Team3")>0))
 {
  ADD("TeamPageList",2);
 }

if ((VALUE("Team1")<1) && (VALUE("Team3")<1))
 {
  ADD("TeamPageList",1);
 }

End Unverified


TeamPage3ConList
Begin Unverified Perl

if ((VALUE("Team1")>0) && (VALUE("Team2")>0))
 {
  ADD("TeamPageList",3);
 }

if ((VALUE("Team1")>0) && (VALUE("Team2")<1))
 {
  ADD("TeamPageList",2);
 }

if ((VALUE("Team1")<1) && (VALUE("Team2")>0))
 {
  ADD("TeamPageList",2);
 }

if ((VALUE("Team1")<1) && (VALUE("Team2")<1))
 {
  ADD("TeamPageList",1);
 }

End Unverified


This all worked perfectly.

For your situation, you simply need to pick any question on each of the Team1, Team2 and Team3 pages and use those variables in your constructed lists code.

Instead of using the VALUE function, you can also use the ANSWERED or SHOWN functions.
answered Oct 28, 2012 by Paul Moon Platinum (75,480 points)
Thanks, Paul - it's me who asked the question - just didn't bother to sign in first.  I'll give this a shot.  I'll do it in a loop - 20 teams long-hand would probably do my head in.  I tried something similar (but not completely the same) and it would still keep counting when I went back.  The other thing I thought of is randomising based on a constructed list.  Will let you know how I go.
0 votes
OK ... got an answer to my own question.  Only slightly different to Mr Moon's, but I'll put it in here for educational purposes (and in case I need it again and can't find it <grin>)

1. Ascertain the subset of teams to be rated. (bog standard AIC for this).  Randomize the list.
2. Instead of using Randomize Pages, use Randomize Blocks, and base the randomization on the list just created.
3. Create a new parent list (RandomList) just with numbers 1 to 17 in it.
4. Create a new constructed list for each of the teams thus:

Begin Unverified Perl

my $i = 0;

for ($i=1; $i<=17; $i++)
{
  if(LISTVALUE("SupportRate",$i) == 1)
  {
    ADD("RandomList",$i);
  }
}

End Unverified



where "==1" changes depending on the team number/member number in the original team list that the list SupportRate is derived from.  (Acknowledged that lists aren't strictly necessary here - you can just as easily build the perl straight into the question headers.  The thing is that if the number of teams changes, I find it easier to just go down a bunch of lists rather than find and click on the individual questions.)

The bit (if you're going to build lists) that goes into the questions is:


Team [%listlabel(Team1,1)%] of [%numchecked(Support)%] 

answered Oct 28, 2012 by Marion Bronze (3,600 points)
0 votes
Not a full answer, but I think the Shown() and Answered() functions are helpful in cases like this.  For example, instead of building a separate variable counter, just add up the results of those functions:
[% Begin Unverified Perl
ANSWERED("Q1") + ANSWERED("Q2") + ANSWERED("Q3")
End Unverified%] of 3


True/False statements return 0/1 when used in Unverified Perl.
answered Oct 29, 2012 by Brian McEwan Gold Sawtooth Software, Inc. (39,370 points)
edited Oct 29, 2012 by Brian McEwan
...