Welcome to the LimeSurvey Community Forum

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

Randomly Select Question Groups

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 3 weeks ago #196022 by tpartner
Replied by tpartner on topic Randomly Select Question Groups
Sorry, I can't think of anything within Expression Manager that will allow you to shorten it.

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: Jane
The topic has been locked.
More
4 years 2 weeks ago #196692 by Matherion
Replied by Matherion on topic Randomly Select Question Groups
Because we're working on a survey with ~ 275 groups, I tried to find a way that's more scalable. By using the {self.gsec} variable and storing its value in an equation question within each group, and then checking whether that value is still lower than the desired number of questions (adding/subtracting what is needed given preceding groups), you eliminate the need to sum increasingly long strings.

In the example, there's a slider question resulting in a numerical value stored in {nrOfQuestions_nr}; every group contains a {group1seq} equation question that contains {self.gseq}; and all the questions in that group have as relevance equation {group1seq <= nrOfQuestions_nr} (in this example, the only preceding group is the one with the slider, and since {self.gseq} starts counting at 0, that works out nicely without the need for additional subtraction or addition).

I would have preferred this to be safer/more scalable/more maintainable by using as relevance equation {self.gseq <= nrOfQuestions_nr}, but for some weird reason that doesn't work. Anybody have any ideas why that could be? Shouldn't all values available in equation questions also work in relevance equations, since both use the expression manager? :blink:

I've attached an example survey that implements this.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose