Looping through a set of Questions (Sub-surveys?)

More
5 years 3 months ago #73497 by tacman1123
tacman1123 created the topic: Looping through a set of Questions (Sub-surveys?)
I'm pretty sure this can't be done in 1.92, but might be supported in LS2. I have a set of questions that I need to loop though, with different field types. For example, let's say the questions are about your children. I want a button that says "Add Child" which pops up a mini-survey -- what's the child's name? Gender? Birthdate? In-school? History of medical issues?

All of those are different field types, it would be nice to have validation.

One solution is to use a text array. This is a hack for several reasons -- you have to artificially limit the number of children, and the format of an array means that very field is just text, and is the same size, so in_school (which should be a checkbox) takes up the same amount of space as medical_history.

Another solution is to have a separate survey of children, and make sure the token is set to allow multiple uses of it, as described in docs.limesurvey.org/Iterate+Survey but this seems a bit suspect as well.

Other ideas (besides waiting for version 2)?

Tac

Please Log in to join the conversation.

More
5 years 3 months ago #73502 by TMSWhite
TMSWhite replied the topic: Looping through a set of Questions (Sub-surveys?)
You can do this in 1.92. LS2 uses the same EM engine that 1.92 uses, so no need to wait for it.

Here's how I've done it in the past:
(1) Create a group that allows you to ask any and all questions you might want to ask about the child. Embed conditions or relevance equations to only ask the questions you need. Also embed any required validation logic.
(2) Export that group, and re-import it as many times as you need. Although you don't want to set an artificial limit, it is probably safe to assume that a parent won't have more than 20 children, for example - so import the group 20 times.
(3) On a page before this set of repeating groups, ask the user how many children they have - let's call that variable "numKids"
(4) For each group, change the group description to make it more readable - e.g. "Child #1", "Child #2", ...
(5) Change the group-level relevance for each group. So, for Child #1, the group-level relevance would be numKids >= 1 and for Child #8, it would be numKids >= 8

Note, you should really change the variable names within each of the groups - adding a prefix or suffix to indicate which child you are referring to - otherwise when you export to SPSS or R your variable labels will be confused. However, for backwards compatibility with 1.91, if you use the conditions designer instead of relevance, you can re-use the same question names within group and still be sure that the appropriate conditions will be applied. If you Show Logic File, you'll see a number of "pink" warnings, but the survey itself should work.

Please Log in to join the conversation.

More
5 years 3 months ago #73509 by Mazi
Mazi replied the topic: Looping through a set of Questions (Sub-surveys?)

TMSWhite wrote: (5) Change the group-level relevance for each group. So, for Child #1, the group-level relevance would be numKids >= 1 and for Child #8, it would be numKids >= 8

You can also do that by using conditions. Set a condition on the first question of the group like "Show question X if question Y was answered ">=3"". then copy that condition to all following questions of that group. Set conditions for following groups as well, using "...answered >=4" and so on.


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

More
5 years 3 months ago #73531 by tacman1123
tacman1123 replied the topic: Looping through a set of Questions (Sub-surveys?)
Brainstorming: suppose I separated out the children question (it's not really a children question, but it's easier to describe that way) into a separate survey.

I could use the iterate survey feature, and allow a single token to access the survey multiple times. Then my only question is how to list the surveys on a page so you know whether or not to edit a survey or add a new one.

In other words, on the main list surveys page, I want to list my main survey, list the survey RESULTS of the "children" survey, with the option of adding a new "child".

So I'd see the following surveys:
Family Survey
List Children:
Michael 10/12/71 Male [edit]
Kathleen 9/1/75 Female [edit]
[Add Another Child]

Is there a way to do that in the current scripting language? Or would it need to be completely external?

Tac

Please Log in to join the conversation.

More
5 years 3 months ago - 5 years 3 months ago #73566 by Mazi
Mazi replied the topic: Looping through a set of Questions (Sub-surveys?)
All this has to be coded. I have done similar work for 2-3 customers of mine and coding your own overview page as you described above using PHP is possible and probably the best way to do so.


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"
Last Edit: 5 years 3 months ago by Mazi.

Please Log in to join the conversation.

More
5 years 3 months ago #73606 by dbrd
dbrd replied the topic: Looping through a set of Questions (Sub-surveys?)

tacman1123 wrote: Brainstorming: suppose I separated out the children question (it's not really a children question, but it's easier to describe that way) into a separate survey.....

Tac


I approach it as TMSWhite suggested:

"(2) Export that group, and re-import it as many times as you need. Although you don't want to set an artificial limit, it is probably safe to assume that a parent won't have more than 20 children, for example - so import the group 20 times."

The export and re-import is easy, and if minor editing of text is needed, of a question code for example, a quick search and replace in a text editor will work.

This is how I construct my surveys, which require going through a group of questions multiple times.

Please Log in to join the conversation.

More
5 years 3 months ago #73615 by Mazi
Mazi replied the topic: Looping through a set of Questions (Sub-surveys?)
That is also the approach we recommend for looping.


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

More
2 years 7 months ago #113085 by david2013
david2013 replied the topic: Looping through a set of Questions (Sub-surveys?)
Does Limesurvey able to do "Looping" so that we just need to create one set of questions, and we can specify number of time to loop through?

Please Log in to join the conversation.

More
2 years 7 months ago #113089 by DenisChenu
DenisChenu replied the topic: Looping through a set of Questions (Sub-surveys?)

david2013 wrote: Does Limesurvey able to do "Looping" so that we just need to create one set of questions, and we can specify number of time to loop through?

No,

not actually

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
1 year 5 months ago #129040 by bogotan
bogotan replied the topic: Looping through a set of Questions (Sub-surveys?)
I have the same problem but I have to many childrens (more than 10), really persons in the same household, and to many questions (300), I think its to many for mysql (limit colums 4096 ).

there is a way to duplicate records of housing in a new record in the database to not repeat the number of questions?

I believe its better explained in the picture, my idea is not replicate questions in colums but in rows
Attachments:

Please Log in to join the conversation.

More
1 year 5 months ago #129057 by tpartner
tpartner replied the topic: Looping through a set of Questions (Sub-surveys?)
If using tokens, you can set multiple-uses for the tokens. At the end of the survey ask if they have any more household members and, if so, redirect back to the survey URL.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: bogotan

Please Log in to join the conversation.

More
1 year 5 months ago - 1 year 5 months ago #129066 by bogotan
bogotan replied the topic: Looping through a set of Questions (Sub-surveys?)
Thanks for the answer!

But the second member have to repeat answer of all questions answered by the first member for the household, I meant number of bedrooms, bathrooms, home ownership ...

Exist a way to copy all house answers and start with the questions of the second person in a new record?

Thanks!
Last Edit: 1 year 5 months ago by bogotan.

Please Log in to join the conversation.

More
1 year 5 months ago #129081 by tpartner
tpartner replied the topic: Looping through a set of Questions (Sub-surveys?)
I would put conditions/relevance on all of those questions so they could be hidden for the subsequent members. Then you could append a value the the redirect URL to preload a hidden question that triggers the conditions/relevance.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now