Have an idea?

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

Constructed lists within loops

Just checking here for some helpful comments.

Assume Q1 is a multiple response select question within a loop with 3 iterations.

I also have Q5 which is a single response select question within a loop with 3 iterations.

At Q5, I would like to display the codes mentioned at Q1 for each specific iteration.


Responses mentioned at Q1 ...
Q1 - Iteration 1: 2,3
Q1 - Iteration 2: 5,9,10
Q1 - Iteration 3: 11,12,13,15

So at Q5, the codes to display are ...
Q5 - Iteration 1: 2,3
Q5 - Iteration 2: 5,9,10
Q5 - Iteration 3: 11,12,13,15

I used a constructed list as follows ...
Begin Unverified Perl 

 if (LOOPVALUE()==1)
 elsif (LOOPVALUE()==2)
 elsif (LOOPVALUE()==3)

End Unverified

Is this the best approach?

It appeared to work okay as I was testing.

But when I used the back button, changed answers at Q1, and then went forward again, I seemed to have some odd behaviour as if the constructed lists had not recalculated for Q5?

Many thanks.
asked Feb 17, 2020 by Paul Moon Platinum (98,990 points)

1 Answer

0 votes
Did you test it with just a normal AIC rather than the dot notations?  I've dealt with this in the past but can't recall where I landed with it.  I can try some testing in a bit.
answered Feb 17, 2020 by Jay Rutherford Platinum (50,755 points)
I did some testing with the standard AIC, and it appeared to not work at Q5?

It seemed to skip Q5?

I'm just seeking advice on the best approach for constructed lists within loops?

The odd behaviour had me somewhat concerned.
Jay, for this survey, I am using v9.3.1.

I just spotted this comment in the version history ...

"Questions inside of a nested loop would not load if the first iteration of the nested loop was skipped due to an empty constructed list."

In my situation, I can get this instance occurring?

Happy for you to continue your testing. I'll need to check in with Sawtooth here.
I have 9.6.1, 9.7.2 and 9.8.0 installed so I may experience different results.
I'll report back top this post after contacting Sawtooth Software.

Stay tuned mate.
I believe regular AIC would work if these two questions both appeared as part of the same loop, but it sounds like that might not be the case here.  With two loops, AIC cannot infer which iterations of the second loop it should associate with which iterations of the first loop.

Looks like you've already got working code, but it might be possible to clean it up and make it easier to manage if the number of iterations ever increases:

Begin Unverified Perl
AIC('Q1.' . LOOPVALUE(), 1, 15);
AIC('Q1.' . LOOPVALUE(), 16);
End Unverified