Welcome, Guest
Username: Password: Remember me

TOPIC: Quotas with array

Quotas with array 3 years 1 week ago #69370

  • cegreja
  • cegreja's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 25
  • Karma: 0
Hi.

I'd like to set up a quota using an array question. Is there any workaround I can use?

Thanks
The administrator has disabled public write access.

Re: Quotas with array 3 years 1 week ago #69387

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4362
  • Thank you received: 827
  • Karma: 381
You will need to use JavaScript load a hidden question based on the array results. The hidden question could then be used for a quota.

The details of the script would depend on your requirements. Can you be more specific?
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: Quotas with array 3 years 1 week ago #69390

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5423
  • Thank you received: 307
  • Karma: 252
Currently quotas are limited to the question types listed here: docs.limesurvey.org/tiki-index.php?page=...orted_question_types

To include an array question you have to modify the source code. If you plan to do so, please have a look at docs.limesurvey.org/How+to+contribute+new+features previously.

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: Quotas with array 3 years 1 week ago #69398

  • cegreja
  • cegreja's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 25
  • Karma: 0
Right. My array is attached.

I want the survey to end if people answer None (first option, "Nenhum") in both cases. If this option is selected in one line, but not in the other, there is no problem.

Thanks

[attachment:1]C:\fakepath\array.doc[/attachment
Attachments:
Last Edit: 3 years 1 week ago by cegreja.
The administrator has disabled public write access.

Re: Quotas with array 3 years 1 week ago #69401

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5423
  • Thank you received: 307
  • Karma: 252
A workaround might be to set conditions for this case. Show a boilerplate with a termination message if the condition is true, otherwise show the following questions (on which you also have to put conditions).

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: Quotas with array 3 years 6 days ago #69412

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

2) Create your array question and a following short-text question (we'll hide this with JavaScript).

3) Put a quota of 0 on the hidden question. If the hidden question equals "1", apply the quota.

4) Add the following script to the source of the array. Replace "AA" with the array question ID and "HH" with the short-text question ID.

The script puts a listener on the array cells. If more than one in the first column are clicked the hidden short-text is set to "1", otherwise it is set to null.
<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
 
		var qArray = AA;
		var qHidden = HH;
 
		// Hide the hidden question
		$('#question'+qHidden+'').hide();
 
		// Add a class to the first column radios
		$('#question'+qArray+' table.question tbody').each(function(i, el){
			$('td:first', el).addClass('col1');
		});
 
		// Listener on the radios
		// If more than 1 checked, the hidden question is set to "1"
		$('#question'+qArray+' table.question tbody td').click(function(){
 
				// A small delay to allow the radio to be checked
				setTimeout(function() {
				if($('.col1 input.radio:checked').length > 1) {
					$('#question'+qHidden+' input.text').val(1);
				}
				else {
					$('#question'+qHidden+' input.text').val('');
				}
			}, 500); 
		});
 
	});
</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.

Re: Quotas with array 3 years 6 days ago #69424

  • cegreja
  • cegreja's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 25
  • Karma: 0
I tried to use the script but I couldn't find the question in the quotas section - maybe because we also can't use short text questions to define a quota and the hidden question is a short text?

Anyway, I'll use the conditions instead of the quotas.

Thanks
The administrator has disabled public write access.

Re: Quotas with array 3 years 6 days ago #69438

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4362
  • Thank you received: 827
  • Karma: 381
...maybe because we also can't use short text questions to define a quota...
Damn, totally zoned on that!

Use a yes-no question and this script will set it to "Yes" if more than one option is selected from the first column.
<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
 
		var qArray = AA;
		var qHidden = HH;
 
		// Hide the hidden question
		$('#question'+qHidden+'').hide();
 
		// Add a class to the first column radios
		$('#question'+qArray+' table.question tbody').each(function(i, el){
			$('td:first', el).addClass('col1');
		});
 
		// Listener on the radios
		// If more than 1 checked, the hidden question is set to "1"
		$('#question'+qArray+' table.question tbody td').click(function(){
 
				// A small delay to allow the radio to be checked
				setTimeout(function() {
				if($('.col1 input.radio:checked').length > 1) {
					$('#question'+qHidden+' input.radio:eq(0)').attr('checked', true);
				}
				else {
					$('#question'+qHidden+' input.radio:eq(1)').attr('checked', true);
				}
			}, 500); 
		});
 
	});
</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.
Moderators: ITEd
Time to create page: 0.133 seconds
Donation Image