Check out the LimeSurvey source code on GitHub!

Quotas with array

More
5 years 3 months ago #69370 by cegreja
Hi.

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

Thanks

Please Log in to join the conversation.

More
5 years 3 months ago #69387 by tpartner
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.

Please Log in to join the conversation.

More
5 years 3 months ago #69390 by Mazi
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)survey-consulting.com'"

Please Log in to join the conversation.

More
5 years 3 months ago - 5 years 3 months ago #69398 by cegreja
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: 5 years 3 months ago by cegreja.

Please Log in to join the conversation.

More
5 years 3 months ago #69401 by Mazi
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)survey-consulting.com'"

Please Log in to join the conversation.

More
5 years 3 months ago #69412 by tpartner
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.

Please Log in to join the conversation.

More
5 years 3 months ago #69424 by cegreja
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

Please Log in to join the conversation.

More
5 years 3 months ago #69438 by tpartner

...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.

Please Log in to join the conversation.

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