Welcome, Guest
Username: Password: Remember me

TOPIC: Limit number of questions in survey

Limit number of questions in survey 1 year 1 month ago #99709

  • Breut
  • Breut's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 7
  • Karma: 0
Hi all,

I'm using 2.00+ build 130708

I have 6 groups with 40+ questions in each group.
I would like to limit the number of questions shown from each group to the person taking the survey, e.g. show 10 random questions from group 1, 15 random questions from group 2 etc.

Please advise on how to proceed.

Thanks in advance,
Thomas
Last Edit: 1 year 1 month ago by Breut. Reason: excess text
The administrator has disabled public write access.

Limit number of questions in survey 1 year 1 month ago #99713

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4293
  • Thank you received: 810
  • Karma: 373
Assuming you are using "group-by-group" mode, you can randomize the question order in each group and then use JavaScript to hide all but the first n questions.

Details of the script may vary by template but would look something like this:

<script type="text/javascript" charset="utf-8">	
	$(document).ready(function(){
 
		var questionsShown = 10;
 
		$('div[id^="question"]').each(function(i) {
			if(i >= questionsShown) {
				$(this).hide();
			}
		});
	});
</script>
Cheers,
Tony Partner

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

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Limit number of questions in survey 1 year 1 month ago #99718

  • Breut
  • Breut's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 7
  • Karma: 0
Thanks for your answer, however I forgot to mention I need to use question by question mode.

Anyway I see where you are getting at - would it be possible with the question by question mode and if yes, where do I implement the Javascript code?

Thanks
The administrator has disabled public write access.

Limit number of questions in survey 1 year 1 month ago #99747

  • Breut
  • Breut's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 7
  • Karma: 0
Hi,

@Tony, the reason why I need to use question by question mode is because I need total randomisation of the questions. In another thread I posted the issue of totally randomizing between groups but as this wasn't answered I needed to revert to using the question by question mode.

This being said, I found an almost working solution using the Expression Manager but it's not that elegant so comments and improvements welcome.

Assume I want 10 questions of N to be displayed
  • I defined a hidden question before all regular questions with code numQuestions and numerical value = 0
  • I then added 1 to that numerical value each time a question is shown
  • I then added the relevance equation numQuestions<=10

This way of working does the trick, however:
  • In each "regular" question I now have a numerical value showing up as adding 1 to the numQuestions variable shows that new value. Question is can I hide this value?
  • When the relevance equation is false (so numQuestions is > 10) an "empty" question is shown while taking the survey that needs a click on the "next" button in order to move on. This is really awkward. Why is this question shown as the relevance equation is false? How can I get rid of it?

Thanks for advising on whether this is a good way to go about this and how to solve these issues.

PS: To be even more specific, there are multiple numQuestions variables running through each other as they mimick the 'groups' I mentioned before (so numQuestionsG1, numQuestionsG2, etc). Again, this works fine but shows an "empty" question per group the moment the relevance equation goes over the threshold of 10 shown questions.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.114 seconds
Donation Image