Welcome to the LimeSurvey Community Forum

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

Recalculate equation question to use in conditions for a subsequent group

  • qsmart
  • qsmart's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 months 1 week ago #251173 by qsmart
LimeSurvey version: 5.4
==================
I have a survey that is structured:
  • Group 1
    • Q 1
    • Q 2
    • Terminate Q 1
  • Group 2 (condition is_empty(Terminate Q 1))
    • Q 1
    • Q 2
    • Terminate Q 2
  • Group 3 (condition is_empty(Terminate Q 1) && is_empty(Terminate Q 2))
    • Q 1
    • Q 2
    • Terminate Q 3
  • ...
  • Group n (condition is_empty(Terminate Q 1) && is_empty(Terminate Q 2) && is_empty(Terminate Q 3) && ... && is_empty(Terminate Q n-1))
    • Q 1
    • Q 2
    • Terminate Q n
  • Group n+1 (condition is_empty(Terminate Q 1) && is_empty(Terminate Q 2) && is_empty(Terminate Q 3) && ... && is_empty(Terminate Q n))
    • Q 1
    • Q2
  • Group n+2 (condition is_empty(Terminate Q 1) && is_empty(Terminate Q 2) && is_empty(Terminate Q 3) && ... && is_empty(Terminate Q n))
    • Q 1
    • Q 2
  • etc...
  • Termination Group (condition !(is_empty(Terminate Q 1) && is_empty(Terminate Q 2) && is_empty(Terminate Q 3) && ... && is_empty(Terminate Q n)))
    • Q 1
Is it possible to have a survey such that:
  • Group 0
    • Equation Q {if(is_empty(Terminate Q 1) && is_empty(Terminate Q 2) && ... && is_empty(Terminate Q n), "True","False")}
  • Group 1 (condition Equation Q == "True")
    • Q 1
    • Q 2
    • Terminate Q 1
  • Group 2 (condition Equation Q == "True")
    • Q 1
    • Q 2
    • Terminate Q 2
  • Group 3 (condition Equation Q == "True")
    • Q 1
    • Q 2
    • Terminate Q 3
  • ...
  • Group n (condition Equation Q == "True")
    • Q 1
    • Q 2
    • Terminate Q n
  • Group n+1 (condition Equation Q == "True")
    • Q 1
    • Q 2
  • Group n+2 (condition Equation Q == "True")
    • Q 1
    • Q 2
  • etc...
  • Termination Group (condition Equation Q == "False")
    • Q 1
where the Equation Q is recalculated before proceeding to the next group.
The point of this is ease of use such that if I were to add another group with a termination question in between Groups 2 and 3, I would only have to change the equation once instead of changing it in every group separately. I'm looking for a solution that doesn't add more questions or force the group conditions to (potentially) be extremely long.
 

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 months 1 week ago #251174 by Joffm
Is there a special reason that you use these group conditions instead of screening out these respondents by a quota?

But you may use a hidden question (Q0) at the start and always assign your termination result (0 or 1).
Then the condition may only be
"Q0==0".

Joffm 

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 months 1 week ago #251191 by Joffm
Hi, if you think about it, you will see that this absolutely unnecessary.
Group n (condition is_empty(Terminate Q 1) && is_empty(Terminate Q 2) && is_empty(Terminate Q 3) && ... && is_empty(Terminate Q n-1))

It's sufficient:
Group n is asked, if
  • Group n-1 was asked (checked either by property ".relevanceStatus" or by "!is_empty(a mandatory question)" )
  • Terminate Q n-1 is false or empty (depends on the type)
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

  • qsmart
  • qsmart's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 months 1 week ago #251223 by qsmart
Joffm,

Thanks for your help! The reason I am not using quotas is because there is a group of questions at the end that I only ask if any of the Termination Qs has been triggered. I did try your other suggestion first of adding !is_empty(a mandatory question from Group n-1) to the Group n condition but because I change the order of the groups so frequently, this quickly became inconvenient.

The problem I've run into now is that once a Termination Q is hit and the participant goes to the Termination Group, they can no longer go back one page and change their answers. Instead it takes them back to the beginning of the survey. I'm still deciding whether or not this is a problem that warrants fixing, but do you know of any quick fixes for this?

Thanks!

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 months 1 week ago #251266 by Joffm
Well, then maybe it is better to use my first hint.

Create a hidden question at the start of the survey, after each "Terminate n" assign the new value to it. (e.g. 0 or 1)
Now your conditionof each group is only "Q0==0" with 0 = no termination

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

  • qsmart
  • qsmart's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 months 1 week ago #251351 by qsmart
I have implemented this, but have run into some problems when hitting the "Previous" button. I was wondering if something like this is possible:
$(document).ready(function() {
    document.getElementById("ls-button-previous").addEventListener("click", clearCalculation);
    function clearCalculation() {
      $('#question{that.HiddenEquation.qid}').val("");
    }
});
Where the equation question empties if the previous button is clicked.
Thanks!

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 months 1 week ago #251357 by tpartner
You cannot manipulate an equation question with JavaScript.

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.

Lime-years ahead

Online-surveys for every purse and purpose