Check out the LimeSurvey source code on GitHub!

Show question/group number in randomized groups

More
5 years 6 months ago #64147 by flink
Hey there,

my Problem is as follows: I set up a questionnaire with 20 items. Every item is actually a group containing 3 questions. One is the actual item and the other two are hidden questions that control time recording and right/wrong counting. The group order is completely randomized by using the _rand()-trick.

What I want to do now is tell the respondet something like "you are currently answering item 12/20". I would normally do that by simply putting this text into the group description (as every group is one item). But since the group order is completely randomized this solution won't work.

Is there any way to realize that? Or, lets say, I'm pretty sure there is a way, because LimeSurvey can literally do everything, but is there somebody who knows how to get it to work?

Thanks in advance and best regards

Flink

Please Log in to join the conversation.

More
5 years 6 months ago #64178 by tpartner
There is a hidden field containing the step number of the displayed group so the following should return the step number:
document.write($('#thisstep').val());

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.

More
5 years 6 months ago #64212 by flink
Hey tpartner,

thank you for your answer. Unfortunately, your code only returns "undefined" when I put it into the group description. What am I doing wrong?

Regards

Flink

Please Log in to join the conversation.

More
5 years 6 months ago #64235 by tpartner
Can you activate a sample survey?

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.

More
5 years 6 months ago #64237 by flink
yes I can. Should I activate it and send you a link, or what do you mean?

Please Log in to join the conversation.

More
5 years 6 months ago #64258 by tpartner
Sure, you can PM me a link or just post it here if it's a sample survey.

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.

More
5 years 6 months ago - 5 years 6 months ago #64327 by tpartner
Ah, it looks like we need to introduce a small delay to allow the form to render.

If using the default template, try:
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		// A small delay to allow the form to render
		setTimeout(function() {
 
			$('.group-description').prepend('<p>Step '+$('#thisstep').val()+'/10</p>');
 
		}, 500);
 
	});
 
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last Edit: 5 years 6 months ago by tpartner.

Please Log in to join the conversation.

More
5 years 6 months ago #64368 by flink
It works! Thank you very much! :)

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form