Expanded vs unexpanded loops: Performance and functionality > Functionality
 
Functionality
This section discusses functionality tests and results. In particular, the tests answer the question of what happens on restart to iterations that have been previously answered but are not asked during this session.
Unexpanded loop behavior
1 On-path survey iteration responses are stored in the database.
2 Off-path survey iteration responses are stored in the database until the survey has completed. When the survey completes, the system attempts to remove off-path data. This succeeds if the survey was completed in one go, or if all restarts were from the cache. If a survey is restarted using sample management, that off-path data is not automatically removed.
3 Questions that are not asked in a restart, are still considered on-path. In the test below, Person[1] and Person[2] are not asked on restart but are on-path.
Diary Studies
The test project asks the respondent to decide if the final iteration has been asked. This makes it easier to run the test but may not be the prevalent scenario. Unexpanded loops can be useful for diary studies where a respondent completes one iteration of a loop each day or each time a product is used. To avoid entering previous iterations each time the study is entered, keep a CurrentDay variable and update it for each instantiation of the interview. This example creates an initial iteration of the loop and initializes CurrentDay on the initial pass through the interview. On subsequent restarts, it retrieves the CurrentDay value from off path data and creates a new iteration of the loop using that value.
' Keep a counter to use to force the new iteration
If Not(IOM.Info.IsRestart) Then
  Set
DiaryDay = Diary[LoopIterations.New]
  CurrentDay = CLong(Mid(DiaryDay.QuestionName, 1))
Else
  CopyOffPathQuestionData(CurrentDay)
  CurrentDay = CurrentDay + 1
  Set DiaryDay = Diary["_" + CText(CurrentDay)]
End If
There must be some indicator that the project is complete. For this example, we have used a question to check for project completion. More likely scenarios are that the interviewing interval has closed or if enough data had been collected. If more iterations of data (diary days for example) are required, terminate the interview with a Stopped signal to allow restart.
LastDay.Ask()
If (LastDay = {Yes}) Then
  
IOM.Terminate(Signals.sigCompleted, True, TerminateStatus.tsCompleted)
Else
  
IOM.Terminate(Signals.sigStopped, True, TerminateStatus.tsScriptStopped)
End If
This is a general CopyOffPathQuestionData function that can be used whenever off path data may be required.
Sub CopyOffPathQuestionData(Question)
  ' We may be snapping back from a point where some of the data is
  
' still on path so keep whichever data is valid
  If Not(Question.Info.IsOnPath) Then
    
Question.Response = Question.Info.OffPathResponse
  End If
End Sub
Test details
Tests
The HDataUnbound.mdd test project has been used to test when an iteration is created, filled, or cleared. The script logic is as follows.
Results
Completing a survey
Step
Question
Response/Selected navigation
Case data
1
HowManyPersons
2 / Next
 
2
Persons[1]
Enter data / Next
Persons 1 iteration added with entered data
3
Persons[2]
Enter data / Next
Persons 2 iteration added with entered data
4
WhichPerson
0 / Next
 
5
Persons[3]
Previous
No data stored for Person 3 because no data was entered
6
WhichPerson
0 / Next
 
7
Persons[4]
Enter data / Previous
Persons 4 iteration added with specified data.
(Since the Previous button was used, this data is not on-path and not off-path data but is stored for usability. If the respondent returns to this page then any valid data will be pre-filled.)
8
WhichPerson
0 / Next
 
9
Persons[5]
Enter Data / Previous
Persons 5 iteration added with specified data.
(Since the Previous button was used, this data is not on-path and not off-path data but is stored for usability. If the respondent returns to this page then any valid data will be pre-filled.)
10
WhichPerson
3 / Next
 
11
Persons[3]
Enter data / Next
Persons 3 iteration added with entered data
12
WhichPerson
-1 / Next
 
 
Completed
 
The completed record contains data for iterations 1, 2, and 3.
Iterations 4 and 5 were removed on completion since they are not on path.
Stop/Restart a survey
In this test, steps 1 through 8 are the same as the previous test.
Timing out and restarting a survey from the URL has the same behaviour.
Step
Question
Response/
selected navigation
Case data
1
HowManyPersons
2 / Next
 
2
Persons[1]
Enter data / Next
Persons 1 iteration added with entered data
3
Persons[2]
Enter data / Next
Persons 2 iteration added with entered data
4
WhichPerson
0 / Next
 
5
Persons[3]
Previous
No data stored for Person 3 because no data was entered
6
WhichPerson
0 / Next
 
7
Persons[4]
Enter data / Previous
Persons 4 iteration added with specified data.
(Since the Previous button was used, this data is not on-path and not off-path data but is stored for usability. If the respondent returns to this page then any valid data will be pre-filled.)
8
WhichPerson
0 / Next
 
9
Persons[5]
Enter data / Stop
Persons 5 iteration added with specified data.
(Since the Stop button was used, this data is not on-path and not off-path data but is stored for usability. If the respondent returns to this page then any valid data will be pre-filled.)
 
Stopped
 
Iterations 1, 2, 4, 5 are stored in the case data.
10
 
Restart from URL using sample ID
 
11
Persons[3]
Enter data / Next
Note: Persons[3] is asked. This indicates that the routing is being replayed and is expected.
Persons 3 iteration filled in with entered data
12
WhichPerson
-1 / Next
 
 
Completed
 
The completed record contains data for iterations 1, 2, 3, 4, and 5.
Iterations 4 and 5 should have been removed but were not. ECM00189184 has been raised for this issue. However the ClearOnExit off path data mode can be used to avoid this issue.
Timeout/Continue a survey
In this test, steps 1 through 8 are the same as the previous tests.
Step
Question
Response/
Selected navigation
Case data
1
HowManyPersons
2 / Next
 
2
Persons[1]
Enter data / Next
Persons 1 iteration added with entered data
3
Persons[2]
Enter data / Next
Persons 2 iteration added with entered data
4
WhichPerson
0 / Next
 
5
Persons[3]
Previous
No data stored for Person 3 because no data was entered
6
WhichPerson
0 / Next
 
7
Persons[4]
Enter data / Previous
Persons 4 iteration added with specified data.
(Since the Previous button was used, this data is not on-path and not off-path data but is stored for usability. If the respondent returns to this page then any valid data will be pre-filled.)
8
WhichPerson
0 / Next
 
9
Persons[5]
Enter data / Timeout
No data stored for Person 5
 
Timed out
 
Iterations 1, 2, and 4 are stored in the case data.
10
 
Restart using Next button
 
11
Persons[5]
Data entered previously / Next
Persons 5 iteration added with entered data
12
WhichPerson
3 / Next
 
13
Persons[3]
Enter data / Next
Persons 3 iteration added with entered data
14
WhichPerson
-1 / Next
 
 
Completed
 
The completed record contains data for iterations 1, 2, 3, and 5.
Iterations 4 was removed because it is not on-path data. This data can be removed if the interview is restarted from the cache.
Next
Test setup
See also
Performance
Cluster configuration
Expanded vs unexpanded loops: Performance and functionality