Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

QUOTA - Terminate if a specific answer has not been checked

  • dariodallago
  • dariodallago's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 11 months ago - 9 years 11 months ago #108009 by dariodallago
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
Last edit: 9 years 11 months ago by holch.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 11 months ago #108025 by tpartner
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.
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 11 months ago #108118 by holch
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 answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 11 months ago #108119 by tpartner
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.
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 11 months ago #108121 by holch
At the moment LS 2.0, but I would like to move it to 2.05. Is there a difference between those two?

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 11 months ago #108122 by tpartner
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.
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 11 months ago #108126 by holch
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 answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 11 months ago #108131 by tpartner
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.

Code:
<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.
The following user(s) said Thank You: dariodallago
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 11 months ago #108135 by holch
Hi Tony!

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

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • dariodallago
  • dariodallago's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 11 months ago #108194 by dariodallago
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:
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose