Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

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

  • tacman1123
  • tacman1123's Avatar Topic Author
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
12 years 1 month ago #73497 by tacman1123
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
The topic has been locked.
  • TMSWhite
  • TMSWhite's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
12 years 1 month ago #73502 by TMSWhite
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.
The topic has been locked.
  • Mazi
  • Mazi's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
12 years 1 month ago #73509 by Mazi

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
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.
  • tacman1123
  • tacman1123's Avatar Topic Author
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
12 years 1 month ago #73531 by tacman1123
Replied by tacman1123 on 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
The topic has been locked.
  • Mazi
  • Mazi's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
12 years 1 month ago - 12 years 1 month ago #73566 by Mazi
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
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
Last edit: 12 years 1 month ago by Mazi.
The topic has been locked.
More
12 years 1 month ago #73606 by dbrd

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.
The topic has been locked.
  • Mazi
  • Mazi's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
12 years 1 month ago #73615 by Mazi
That is also the approach we recommend for looping.

Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.
More
9 years 5 months ago #113085 by david2013
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?
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 5 months ago #113089 by DenisChenu
Replied by DenisChenu on 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 , plugin development .
I don't answer to private message.
The topic has been locked.
More
8 years 3 months ago #129040 by bogotan
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
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 3 months ago #129057 by tpartner
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
The topic has been locked.
More
8 years 3 months ago - 8 years 3 months ago #129066 by bogotan
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: 8 years 3 months ago by bogotan.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose