I am creating a travel diary in as a loop. It goes as follows (will look similar).
Q1: Which days of the week do you commute to work (checkbox)
--this feeds into the loop list and goes from Sunday (1) to Saturday (7)
Loop begins
Q3: was your commute mode for day 2 the same as day 1?
--If they answer 'yes' to this the next loop is skipped.
Q2: what were your commute modes for day 1 (checkbox)
The loop is a bit interesting. Q3 is actually the first question in the loop, but I have a post skip on Q1 to always skip to Q2. I have a post skip on Q3 to skip to the next loop iteration if Q3 == 2 (yes).
Upon exiting the loopI am trying to count the number of times a respondent drives alone. so Q2_1 == 1. The initial difficulty was if they say 'yes' to Q3 then they skip the next loop, but I found out I fix that by doing the following in perl:
if (GETVALUE("Q3.2") == 2 ) { # 2 is 'yes"
SETVALUE("Q2.2",GETVALUE("Q2.1"));
}
I thought this worked then realized it only works if a respondent commutes on consecutive days only. If a respondent commutes on Monday, Wednesday and Friday then the script does not work. Here is a scenario:
The first loop iteration is skipped because the respondent does not commute on Sunday
Q3.2 - always skipped due to the post-skip on Q1
Q2_1.2 == 1
The third loop iteration is skipped because the respondent does not commute on Tuesday
Q3.4 == 2 - respondent's commute mode on Wednesday is the same as it was on Monday. Respondent skips to the next loop iteration.
The fifth loop iteration is skipped because the respondent does not commute on Thursday.
Q3.6 == 2 - respondent's commute mode on Friday is the same as it was on Monday. Respondent skips to the next loop iteration....this is the last loop iteration. Respondent exits the loop.
Now, the code above does not work and the variables for iterations 4 and 6 are blank. I need somethig like the following but cannot figure it out.
if (GETVALUE("Q3.thisIteration") == 2 ) {
SETVALUE("Q2.thisIteration",GETVALUE("Q2.lastIterationAskedAbout"));
}
I have been toying with using the loop functions and building some type of constructed list, but cannot wrap my head around it. Help me, you're my only hope.