Professional > Interview scripting > Writing interview scripts > Filtering questions and response lists > Filtering loops > Random filtering for loops > Using random answers from those chosen at a previous question
 
Using random answers from those chosen at a previous question
This method uses an ordinary, unrandomized loop control list. The items that will be used from the list are chosen at random from the answers given to an earlier question. This example is similar to the previous one except that it does not assume that everyone works on all projects. Instead, it asks employees which projects they worked on and then asks for more details about one project chosen at random from each employee’s answer. The metadata is as follows:
ProjectList define
{Project11, Project12, Project13, Project14};
YourProjects "Which projects did you work on last year?" categorical [1..]
{use ProjectList};
ProjectsLoop loop
{use ProjectList}
fields (
Position1 "What was your position in the {@ProjectsLoop} project team?"
categorical [1..1]
{
Designer, Developer, Writer, QA, Manager
};
HowLong1 "How long (in months) did you work on this project?"
long [1..12];
Likes1 "What did you particularly enjoy about this project?"
text;
Dislikes1 "And was there anything you disliked about the project?"
text;
) expand;
The routing statements to ask the questions in the loop about one project chosen at random from those worked on are as follows:
YourProjects.Ask()
Projects.Categories.Filter = YourProjects.Response.Ran(1)
ProjectsLoop[..].Ask()
Another option, and one that does not use filtering at all, is to write:
YourProjects.Ask()
ProjectsLoop[YourProjects.Response.Ran(1)].Ask()
For more information about this syntax, see Asking selected repetitions only.
See also
Random filtering for loops