Controlling Group Logic with Custom Array
Controlling the display order of paths within Group logic, inside or outside of a Smart Loop, can be done using a mix of array and scoring logic. It is not recommended for uses where a max limit is applied to the Group logic or Smart Loop.
First, you must create a reference array that holds the order you want assigned paths to be shown. This is simplest if the array holds values from 1 to the number of paths in your group logic. For example, if there are five paths, use an array with values 1-5 instead of 2-6. If the desired order is the same as an array that is being used in Sort by logic then that array can be used; a new duplicate array is not needed.
Next, you must create a variable that will track the number of paths seen. This is simplest if this variable is created with a starting value of 1; for example [shownext=1]. It is important that this variable is created for every respondent who will need their path display order controlled by the array logic. This means placing the variable logic on a question that is seen by all of those respondents and is done before entering the Group logic or Smart Loop.
Next, on the LAST question within each path that is seen by everyone assigned to that path, the variable tracking the number of paths seen needs to be incremented by 1. For example, [shownext+1]; make sure to use the same variable name as the initial variable created. It is important that this logic be applied to the last question within a path. If there is conditional show/hide logic on the last question restricting who will see that question, then logic must be used elsewhere to ensure all respondents have their counter increased by one before moving to the next path.
Finally, logic must be added to each question within a path to check if the value in the array that corresponds to a path matches the position to be shown next. In a case where there is more than one question per path, this logic must be applied to all questions or other logic that will only show if a previous question in that path has been answered. If there are other conditions to showing a subsequent question, they must be combined with the conditional logic checking display order.
For example, let's assume a setup of three paths with one question each and that our initial array and variable will be:
[order << 1,2,3][order = shuffle order]
[shownext=1]
On the first path's question, the following logic will check if the path is ready to be displayed based on the array order:
[Show if (order|1=1 and shownext=1)
or (order|2=1 and shownext=2)
or (order|3=1 and shownext=3)][shownext+1]
Here, order is the name of our array, |1 checks for the value of the first value in the array, =1 represents checking for the first path, and the corresponding shownext= condition validates if it is time to show that position. Since it is the only question in the path, and thus the last question in the path, [shownext+1] increments the counter to now look for the next path.
Logic for the second and third path's questions respectively:
[Show if (order|1=2 and shownext=1)
or (order|2=2 and shownext=2)
or (order|3=2 and shownext=3)][shownext+1]
[Show if (order|1=3 and shownext=1)
or (order|2=3 and shownext=2)
or (order|3=3 and shownext=3)][shownext+1]
The only difference in each path's logic is the value is being searched for in the array that corresponds to that path.
Note, if many sets of this logic will be used in the same study, it is important to create a new counter for each set or to reset the counter variable value between sets to the desired starting value (e.g., [shownext=1]).