Welcome, Guest
Username: Password: Remember me

TOPIC: Survey quota based on answer value

Survey quota based on answer value 3 years 6 days ago #65526

  • abdulrs
  • abdulrs's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 5
  • Karma: 0
Hi,
I would like to have a field in my question. For example number of participants. Once it reaches 30 ( sum off all participants ) it should give a message that quota is over.


Quota can be used for fields such as gender or multiple choice, etc. But in this case it's input field / multiple choice but the quota limit is the sum of all the answers.

Is it possible to achieve above functionality ?

Thanks in Advance,
Abdul Raheem
The administrator has disabled public write access.

Re: Survey quota based on answer value 3 years 6 days ago #65532

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4188
  • Thank you received: 786
  • Karma: 359
If you want to limit the survey to 30 respondents, you can put in a hidden radio question and use JavaScript to toggle it. The quota could then be set on the hidden 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.
The administrator has disabled public write access.

Re: Survey quota based on answer value 3 years 5 days ago #65547

  • abdulrs
  • abdulrs's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 5
  • Karma: 0
Hi,
Thank you for taking time to respond. I am breaking my head to find a way to get the sum of all responses so far to set the value in the hidden radio question. But no clue.Can you please brief little more the solution you have mentioned ?

Appreciate your help.
Thanks,
Abdul Raheem
The administrator has disabled public write access.

Re: Survey quota based on answer value 3 years 5 days ago #65560

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4188
  • Thank you received: 786
  • Karma: 359
1) Set up your survey to use JavaScript.

2) Create a multiple choice question with a single sub-question.

3) Place a quota of 30 on the sub-question.

4) Add the following script to the source of the multiple choice question. Replace "QQ" with the multiple choice question ID.

The script hides the multiple choice question and automatically checks it. This way, the quota will automatically fire for the 31st respondent.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
		$('#questionQQ').hide();
		$('#questionQQ .checkbox').attr('checked', true);
	});
 
</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.
Last Edit: 3 years 5 days ago by tpartner.
The administrator has disabled public write access.

Re: Survey quota based on answer value 3 years 5 days ago #65561

  • abdulrs
  • abdulrs's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 5
  • Karma: 0
Hi,
Thanks for your clear explanation. I think I din't explain my requirement clearly.

For example: I have a question ( Number of participants ) with three subquestions each values 1,2 and 3 respectively.

Capture.PNG


Say,We set the quota of 4. respondent1 selects option 1. and respondent2 selects 3.so the quota consumed to be 3 + 1 = 4. So the quota is full.IT should not allow any further respondents.

Our requirement is to have a field for number of participants.The sum of all the values entered in this filed should not exceed the quota.


Hope this clarifies the requirement .

Pls advise,
Thanks in advance.
Abdul Raheem S
Last Edit: 3 years 5 days ago by abdulrs.
The administrator has disabled public write access.

Re: Survey quota based on answer value 3 years 5 days ago #65562

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4188
  • Thank you received: 786
  • Karma: 359
Oh, I see. In that case, quotas won't help (at least not directly).

I think you will need to fire a remote PHP script to query the database to find the current total and then act accordingly. I'm not a PHP expert so can't help with the details of that script.

Here's an example of how to fire a remote PHP script - www.limesurvey.org/en/forum/can-i-do-thi...on-of-a-survey#55975..
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 days ago by tpartner.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.107 seconds
Donation Image