QUOTA - Terminate if a specific answer has not been checked

More
3 years 3 weeks ago - 3 years 3 weeks ago #108009 by dariodallago
dariodallago created the topic: QUOTA - Terminate if a specific answer has not been checked
Hi,
I'm having some trouble with QUOTA for this specific question (see image attached).

All responents have to check "product B". So I want to automatically terminate the survey if a respondent has not answered "product B".

So, if someone chooses Product B and D, they would continue the survey. If they choose only D, or only A or only C (plus a few other combinations), the survey would automatically terminate.

Can someone help me in this? :blink:
Thank you
Dario
Attachments:
Last Edit: 3 years 3 weeks ago by holch.

Please Log in to join the conversation.

More
3 years 3 weeks ago #108025 by tpartner
tpartner replied the topic: QUOTA - Terminate if a specific answer has not been checked
I think you will need to use JavaScript to interrupt the "Next" function and, if "B" is not checked, click a hidden select-radio question. The quota could the be based on the hidden radio question.


.

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
3 years 3 weeks ago #108118 by holch
holch replied the topic: QUOTA - Terminate if a specific answer has not been checked
Hi Tpartner!

Thank you for the response. Dario is working with me and is trying a few things in Limesurvey at the moment.

We were wondering, if we could do all this with a simple equation. The results of an equation should be written into the database, right? Or do we still have to write the results of the equation via Javascript into a hidden question?

In this case, how would we do this?

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in to join the conversation.

More
3 years 3 weeks ago #108119 by tpartner
tpartner replied the topic: QUOTA - Terminate if a specific answer has not been checked
Hi Holch,

I don't think an equation question will help in this case. As far as I can see, the equation is not a supported question type for quotas.

When I get a chance, I'll attach a small sample survey.

LS 2.0 or 2.05?

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
3 years 3 weeks ago #108121 by holch
holch replied the topic: QUOTA - Terminate if a specific answer has not been checked
At the moment LS 2.0, but I would like to move it to 2.05. Is there a difference between those two?

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in to join the conversation.

More
3 years 3 weeks ago #108122 by tpartner
tpartner replied the topic: QUOTA - Terminate if a specific answer has not been checked
There may be small differences in the JS - 2.05 uses a much newer version of jQuery and some stuff has been deprecated.

I'll do it up for 2.0


.

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
3 years 3 weeks ago #108126 by holch
holch replied the topic: QUOTA - Terminate if a specific answer has not been checked
I really need to freshn up my Javascript. I actually learned it, but then forgot most of it, because I did not use it much. And since then, the importance of Javascript has changed a lot. Before it was more for gimmicks (everyone looked down on it), now it really has found its place and is very important for webdevelopment.

Unfortunately there are still some things that LS (while quite good already), does not offer out of the box. Real screenouts for example. And this is a case where the workaround with the zero quotas fails misserably. But in market research, this is quite a common scenario.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in to join the conversation.

More
3 years 2 weeks ago #108131 by tpartner
tpartner replied the topic: QUOTA - Terminate if a specific answer has not been checked
Okay, so here's a working example.

The survey consists of the product multiple-choice question, followed by a radio question with a single answer. The radio question must be place directly after the multiple-choice.

The radio question is hidden by JavaScript and toggled depending on the "checked" state of a "mandatory" option in the products question.

A quota of 0 is placed on the single answer of the radio question.

The following script is placed in the source of the multiple-choice (I think the comments in the script adequately describe what it does). In this case I defined sub-question code "b" as mandatory.

<script type="text/javascript" charset="utf-8">	
	$(document).ready(function() {
 
		// Identify the questions
		var qID = {QID};
		var thisQuestion = $('#question'+qID);
		var quotaQuestion = $(thisQuestion).nextAll('.list-radio:eq(0)');
 
		// The sub-question code of the mandatory option
		var mandatoryOptionCode = 'b';
 
		// Hide the quota question
		$(quotaQuestion).hide();
 
		// Interrupt the Next/Submit function
		$('form#limesurvey').submit(function(){
 
			// Is the mandatory option checked?
			if($('input.checkbox[id$="X'+qID+mandatoryOptionCode+'"]').is(':checked') == false) {
				// No, so click the quota radio
				$('input.radio', quotaQuestion).click();
			}
			else {
				// Yes, so uncheck the quota radio
				$('input.radio', quotaQuestion).attr('checked', false);
			}
		});
	});
</script>

File Attachment:

File Name: limesurvey...3439.lss
File Size:19 KB

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The following user(s) said Thank You: dariodallago

Please Log in to join the conversation.

More
3 years 2 weeks ago #108135 by holch
holch replied the topic: QUOTA - Terminate if a specific answer has not been checked
Hi Tony!

Many thanks for this. I'll have a look at it later today and then adapt it to our survey.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in to join the conversation.

More
3 years 2 weeks ago #108194 by dariodallago
dariodallago replied the topic: QUOTA - Terminate if a specific answer has not been checked
IT WORKS!
I'll make sure to addapt all things correctly, but most of the work is now done.
Thank you a lot for this, tpartner!

"Sorry, we don't care what you think - get lost!"
:lol:

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now