Welcome to the LimeSurvey Community Forum

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

Condition not working properly after using the previous button and coming back

  • nadica123
  • nadica123's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
2 months 2 weeks ago #266135 by nadica123
Please help us help you and fill where relevant:
LimeSurvey version: 6.3.4
Own server or LimeSurvey Cloud: own server
Survey theme/template: Fruity
==================
(Write here your question/remark)

Hello,

I have a survey where I have 2 closing messages I want to display based on previous answers and a participant attribute. This is the condition for the closing 1:

((is_empty(TOKEN:ATTRIBUTE_13)) and (( ! is_empty(PANELCONSENT.NAOK) && (PANELCONSENT.NAOK == 1))) and (EMAIL.NAOK == "-oth-" or ( ! is_empty(EMAIL.NAOK) && (EMAIL.NAOK == 97)))) or (( ! is_empty(TOKEN:ATTRIBUTE_13)) and (( ! is_empty(PANELCONSENT.NAOK) && (PANELCONSENT.NAOK == 1))) and (MOBILENUM.NAOK == "-oth-" or ( ! is_empty(MOBILENUM.NAOK) && (MOBILENUM.NAOK == 97))) and (EMAIL.NAOK == "-oth-" or ( ! is_empty(EMAIL.NAOK) && (EMAIL.NAOK == 97))))

This is the condition for closing 2:

((is_empty(TOKEN:ATTRIBUTE_13)) and (( ! is_empty(PANELCONSENT.NAOK) && (PANELCONSENT.NAOK == 1))) and (EMAIL.NAOK != "-oth-" or (is_empty(EMAIL.NAOK) || (EMAIL.NAOK != 97)))) or (( ! is_empty(TOKEN:ATTRIBUTE_13)) and (( ! is_empty(PANELCONSENT.NAOK) && (PANELCONSENT.NAOK == 1))) and (MOBILENUM.NAOK != "-oth-" or (is_empty(MOBILENUM.NAOK) || (MOBILENUM.NAOK != 97))) and (EMAIL.NAOK != "-oth-" or (is_empty(EMAIL.NAOK) || (EMAIL.NAOK != 97))))

The logic seems to be fine when email and/or mobilenum are not either code 97 or other and panelconsent is 1 it shows me the closing 2 and skips the closing 1. The issue I'm having is that if you come to closing 2 you can go back and fill in mobilenum and/or email so that you will be shown the closing 1, and the closing 1 indeed is shown, but after that when I click the next button the closing 2 is shown again no matter that the condition is satisfied and is no longer true for closing 2. The same happens when the closing 1 condition is satisfied on the first run, it shows the closing 2 message after the next button is clicked.

Is there something I'm missing in the closing 2 condition?

Thank you.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 months 2 weeks ago #266137 by Joffm
Hi,
at first glance:
These two parts of your condition are useless
MOBILENUM.NAOK != "-oth-" or is_empty(MOBILENUM.NAOK) || MOBILENUM.NAOK != 97
EMAIL.NAOK != "-oth-" or is_empty(EMAIL.NAOK) || EMAIL.NAOK != 97

They are always TRUE (the logical OR operation is TRUE if at least one part is TRUE)
See here:
EMAIL is empty (one part is TRUE: is_empty(EMAIL)
EMAIL==1   (two parts are TRUE: not equal 97, not equal "-oth-")
EMAIL==97 (one part is TRUE: not equal "-oth-")
EMAIL=="-oth-" (one part is TRUE: not equal 97)

Better you send the lss export of this part; we see better, what you want to achieve.

Joffm

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

Please Log in to join the conversation.

  • nadica123
  • nadica123's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
2 months 2 weeks ago #266140 by nadica123
Hello, thank you for your response.

I've attached the .lss file.

File Attachment:

File Name: limesurvey...7946.lss
File Size:254 KB

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 months 2 weeks ago #266147 by Joffm
Hi,
1. You should not use the condition designer; better ExpressionScript.
As written here in the manual
[url] www.limesurvey.org/manual/ExpressionScri...itions_and_Relevance ?[/url]
Pro: 1. Nice GUI for creating simple conditions.
Cons: Only supports simple comparisons and does not "AND" and "OR" conditions well. (and many others)
 
Only one example of nonsense.
((!is_empty(PANELCONSENT.NAOK) && (PANELCONSENT.NAOK == 1))
IF the PANELCO=PNSENT is equal 1 it is obvious that it is not empty. And the superfluous brackets.

So it would be helpful if you explained what exactly has to be fulfilled that the "closing" questions are displayed.

Maybe (probably) I misunderstood things, but I "translated" your condition to
PANELCONSENT.NAOK == 1 AND
(is_empty(TOKEN:ATTRIBUTE_13)  and (EMAIL.NAOK != "-oth-" OR is_empty(EMAIL.NAOK) OR EMAIL.NAOK != 97)) OR
(!is_empty(TOKEN:ATTRIBUTE_13) and (EMAIL.NAOK != "-oth-" OR is_empty(EMAIL.NAOK) OR EMAIL.NAOK != 97) AND (MOBILENUM.NAOK != "-oth-" OR is_empty(MOBILENUM.NAOK) OR MOBILENUM.NAOK != 97))


Considering what I wrote before this is equal to
PANELCONSENT.NAOK == 1 AND
(is_empty(TOKEN:ATTRIBUTE_13)  AND (
TRUE)) OR
(!is_empty(TOKEN:ATTRIBUTE_13) AND (
TRUE) AND (TRUE))

Now either the attribute is empty or not.
PANELCONSENT.NAOK == 1 AND
(is_empty(TOKEN:ATTRIBUTE_13)  AND (TRUE)) OR (!is_empty(TOKEN:ATTRIBUTE_13) AND (TRUE) AND (TRUE))

If it is empty the first part is TRUE, if it is not empty the second part is TRUE.
In total, the entire condition only depends on PANELCONSENT.

But as said before: Probably I misunderstoofd something.
Therefore please explain in your own words, what has to be fulfilled.

Joffm

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

Please Log in to join the conversation.

  • nadica123
  • nadica123's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
2 months 2 weeks ago #266154 by nadica123
Hi,

Thank you for the in-depth reply.

So first of all the panel consent needs to be the option yes (code 1) for the closing1 or closing2 to be displayed, otherwise if any other option selected it will go to closing3.

Second is the attribute 13, if empty then only the email question is filled and if the email question is either other or code 97 then closing1 shows up (which it does currently but closing2 follows and it shouldn't) if it's not other or 97 then closing2 shows up and closing1 is skipped(which currently works)

If the attribute 13 is not empty then two questions are filled in the email and mobilenum which both need to be either other or code 97 in order for the closing1 to show up(which it does currently but closing2 follows and it shouldn't). If the email and/or mobilenum are not other or 97 then closing2 shows up (which currently works).

So I'm confused why only the closing 2 works when at first the conditions are satisfied for closing2, but when I go back to satisfy the condition for closing1 closing 2 also shows up after, even though the condition is no longer safisfied for closing 2.

Thank you.

Please Log in to join the conversation.

More
2 months 2 weeks ago #266157 by dalii0
it would be helpful to create a minimal example survey that demonstrates the issue and share it with the LimeSurvey community for further debugging.

Also\, have you looked at official docs

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 months 2 weeks ago - 2 months 2 weeks ago #266161 by Joffm
Hi,
I think you are confused about negation of  logical operations.
As I wrote before:
!A OR !B is always TRUE, except if A==B. But this is impossible, because of 
A : EMAIL=="-oth-"
B: EMAIL==97

EMAIL.NAOK != "-oth-" OR is_empty(EMAIL.NAOK) OR EMAIL.NAOK != 97
I assume that you want to achieve that
the Email may be empty OR it is not equal to "-oth-" and not equal to "97", or it is empty or equal to 98 or 99

You see the contrary of A OR B is not !A OR !B, but !A AND !B  
 
Old memories of school days

Now: As you screen out people who do not consent, this part is not necessary anymore.

Try:
1.
(is_empty(TOKEN:ATTRIBUTE_13) AND (EMAIL.NAOK == "-oth-" OR EMAIL.NAOK == 97))
OR
(!is_empty(TOKEN:ATTRIBUTE_13) AND (EMAIL.NAOK == "-oth-" OR EMAIL.NAOK == 97) AND (MOBILENUM.NAOK == "-oth-" OR MOBILENUM.NAOK == 97))


2.
(is_empty(TOKEN:ATTRIBUTE_13) AND (is_empty(EMAIL.NAOK) OR EMAIL.NAOK == 98 OR EMAIL.NAOK == 99))
OR
(!is_empty(TOKEN:ATTRIBUTE_13) AND (is_empty(EMAIL.NAOK) OR EMAIL.NAOK == 98 OR EMAIL.NAOK == 99) AND (is_empty(MOBILENUM.NAOK) OR MOBILENUM.NAOK == 98 OR MOBILENUM.NAOK == 99))


Joffm

Edit:
Now I saw that EMAIL is mandatory and always asked. So the condition "es_empty(EMAIL)" is obsolete.
Analogue "is_empty(MOBILNUM)". It is mandatory and always asked if "attribute_13" is not empty. 
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 2 months 2 weeks ago by Joffm.

Please Log in to join the conversation.

  • nadica123
  • nadica123's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
2 months 2 weeks ago #266186 by nadica123
Hello,

Thank you so much for looking into this, I get your point now :)

The suggested conditions indeed worked and all is fine now.

Thanks again!

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose