Check out the LimeSurvey source code on GitHub!

Token variable as Quota (answer)

More
6 years 1 month ago #55546 by id_wahyu
Hi ALL, I am totally new with LimeSurwey, and instantly become FANS!

During my exploration, I have a question need to ask to all LS master out there.
Is that possible to use Token-variable (e.g. ATTRIBUTE_1) as Quota?
Or if it is not, could you please help me show how to "auto fill-in" Question with Token component? ... so in the end I can use this question as Quota control.

As always, many thanks in advance.

Please Log in to join the conversation.

More
6 years 1 month ago #55566 by Mazi
Token data can't be used for quotas (yet). A workaround might be to edit the email invitations and pass the token value by URL when the user starts a survey. Have a new question at the beginning of your survey, e.g. if
surveyID=12345
groupID=22
questionID=333

add this to the end of the survey URL at your email invitations: ...&12345X22X333={ATTRIBUTE_X} where {ATTRIBUTE_X} is the attribute from the token screen containing the value you want to use for quotas.

This way the first question is auto-filled with token data and can be used for quotas.


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
6 years 1 month ago #55575 by id_wahyu
Thanks a lot Mazi. Need to digest one-by-one, will let anyone know any output later on.

Please Log in to join the conversation.

More
6 years 1 month ago #55580 by tpartner
If you're prepared to delve into a little JavaScript you could load a hidden question with the token value as follows:

1) Use {TOKEN:ATTRIBUTE_1} to load the token value into the text or help section of the hidden question.

2) Use JavaScript to retrieve that value and load the answer accordingly.

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
6 years 4 weeks ago #55740 by id_wahyu
Thanks Tony, is there any documentation on how to create the hidden question? [sorry I can't find it somehow].

Please Log in to join the conversation.

More
6 years 4 weeks ago - 6 years 4 weeks ago #55756 by tpartner
You can use CSS or javaScript to hide the question.

Here's an example of passing a token value into the text of a hidden Yes/No question and toggling the question depending on the token value.

1) Set up your survey to use JavaScript .

2) Create a Yes/No question and add something like the following to the source of the question text:
The ATTRIBUTE_1 value is <span class="token1Value">{TOKEN:ATTRIBUTE_1}</span>

3) Add the following code to the source of the question help. Replace "QQ" with the ID of your Yes/No question.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		var qID = QQ;
 
		$('#question'+qID+'').hide();
 
		var token1Val = $('#question'+qID+' .token1Value').text();
 
		if (token1Val == 1) {
			$('#question'+qID+' input.radio:eq(0)').attr('checked', true);
		}
		else {
			$('#question'+qID+' input.radio:eq(1)').attr('checked', true);
		}
 
 
	});
 
</script>

4) Create a token table giving numeric values for Attribute 1.

The JavaScript:
- hides the yes/no question
- gets the token value from the question text
- if the token value is 1, the "Yes" option is selected
- otherwise the "No" option is selected.

You should then be able to set quotas on the Yes/No question.

Cheers,
Tony Partner

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

Please Log in to join the conversation.

More
6 years 4 weeks ago #55800 by id_wahyu
Perfecto Tony, thanks a million!

Please Log in to join the conversation.

More
6 years 4 weeks ago #55844 by Mazi
You're welcome!

If our hints have been helpful and you enjoy limesurvey please consider a donation to the team .
We do all this in our free time and you don't have to pay a penny for this software.

Without your help we can't keep this project alive.


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.

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