Welcome, Guest
Username: Password: Remember me

TOPIC: Token variable as Quota (answer)

Token variable as Quota (answer) 3 years 5 months ago #55546

  • id_wahyu
  • id_wahyu's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 29
  • Karma: 0
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.
The administrator has disabled public write access.

Re: Token variable as Quota (answer) 3 years 5 months ago #55566

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5300
  • Thank you received: 291
  • Karma: 247
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)limesurvey.org'"
The administrator has disabled public write access.

Re: Token variable as Quota (answer) 3 years 5 months ago #55575

  • id_wahyu
  • id_wahyu's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 29
  • Karma: 0
Thanks a lot Mazi. Need to digest one-by-one, will let anyone know any output later on.
The administrator has disabled public write access.

Re: Token variable as Quota (answer) 3 years 5 months ago #55580

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4049
  • Thank you received: 739
  • Karma: 341
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.

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

Re: Token variable as Quota (answer) 3 years 5 months ago #55740

  • id_wahyu
  • id_wahyu's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 29
  • Karma: 0
Thanks Tony, is there any documentation on how to create the hidden question? [sorry I can't find it somehow].
The administrator has disabled public write access.

Re: Token variable as Quota (answer) 3 years 5 months ago #55756

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4049
  • Thank you received: 739
  • Karma: 341
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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Last Edit: 3 years 5 months ago by tpartner.
The administrator has disabled public write access.

Re: Token variable as Quota (answer) 3 years 5 months ago #55800

  • id_wahyu
  • id_wahyu's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 29
  • Karma: 0
Perfecto Tony, thanks a million!
The administrator has disabled public write access.

Re: Token variable as Quota (answer) 3 years 5 months ago #55844

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5300
  • Thank you received: 291
  • Karma: 247
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)limesurvey.org'"
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.115 seconds
Donation Image