Conditional Question Group - Answers not Saving

More
2 months 1 day ago #220549 by mbraun
Hi everyone,

I am relatively new to limesurvey and got stuck on something. I tried checking the handbook and the forum but was unable to find what I was looking for..

I am currently making a survey which some conditionalities and I used the relevance equation for this. I have an entire question group that should only be shown under the following condition

(var1.NAOK== "A1")
and (var2.NAOK == "A1")
and (((var3a * var3b.NAOK * 8) + (var4a * var4b.NAOK * 4) + (var5a * var5b.NAOK * 3.3)) <= 600)

var1 and var2 are List(radio) and var3a - var5b are numericals, with the b's being conditional on the a's (e.g. 3b is only shown if 3a != 0, same for the others).

I used this for this question group as well as some later questions and it seemed to work perfectly in the preview ( = the questions appeared when they were supposed to appear). However, when looking at my question group, it doesn't display the entire relevance equation (only until var5b.NAOK * 3.3))  and marks the first bracket claiming it is missing a closing parentheses. This error message does not appear on the individual questions that I used this relevance equation on, only when I'm using it for a question group.

Today I activated my survey for the first time and quickly noticed that the results of the entire question group do not get saved at all. I assume it was something to do with the relevance equation (results do get saved when I set it to 1) but am unsure how to proceed now.

Kind regards,
Maya

Please Log in to join the conversation.

More
2 months 1 day ago #220551 by holch
In cases as specific as yours it is always good to include a LSS file with only the relevant part of your survey, so we can can have a look at it.

Also, always mention the version of Limesurvey that you are using.

And with a formula like this

(((var3a * var3b.NAOK * 8) + (var4a * var4b.NAOK * 4) + (var5a * var5b.NAOK * 3.3)) <= 600)


I would always create a step in between to test. Create a equation question where you calculate that value ((var3a * var3b.NAOK * 8) + (var4a * var4b.NAOK * 4) + (var5a * var5b.NAOK * 3.3)) and you can see if the value is calculated correctly. Later you just check if the value saved in this equation question is equal or smaller than 600. When you do it in smaller steps, it is easier to check for errors.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The following user(s) said Thank You: mbraun

Please Log in to join the conversation.

More
2 months 1 day ago #220554 by tpartner
Be careful using the plus operator, ExpressionScript may see that as a text string.

This is safer:

(sum(var3a.NAOK * var3b.NAOK * 8, var4a.NAOK * var4b.NAOK * 4, var5a.NAOK * var5b.NAOK) * 3.3 <= 600)

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: holch, mbraun

Please Log in to join the conversation.

More
2 months 21 hours ago #220566 by mbraun
Thanks to both of you. I tried both of your advice. My survey is in attachment. The relevant parts are the IPAQ questions and the "Over u" question group. I tried saving the results in "IPAQResultaat" using sum as suggested, and the conditionalities once again seem to work. However, the issue with saving remains the same. I also noticed that IPAQResultaat does not save as a number but as NAN.

The relevance equation also still gets displayed weirdly in the group summary, leaving the last parts out and then complaining about a missing bracket

( var == "A1") && ( var == "A1") && ( result
Attachments:

Please Log in to join the conversation.

More
2 months 20 hours ago #220576 by Joffm
Hi, Maya,
are you sure you sent the correct survey?
In this sent survey there is only one question, one to limit the number of answers per row in an array/(numbers).

Furthermore this sent survey was created in a Limesurvey version ... what 1.92?

Best regards
Joffm


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

Please Log in to join the conversation.

More
2 months 19 hours ago #220578 by mbraun
Let's try that again! Sorry for this and thank you everyone for your patience and help!
Attachments:

Please Log in to join the conversation.

More
2 months 18 hours ago #220581 by Joffm
Hi, Maya,

The relevance equation also still gets displayed weirdly in the group summary, leaving the last parts out and then complaining about a missing bracket

The condition worked but the logic file complaind.
In my opinion it is because of the "<=". The editor might see it as the start of a tag (like <span>).
Change to
OfAge.NAOK == "A1" && Gezondheid.NAOK == "A1" && IPAQResultaat.NAOK le 600

And I see no issue in saving the Resultaat
 

What you can try is to set the equation into the question text, not in this "equation field"
 
You see I removed some obsolete brackets.


If there are errors you will see it better.

 

File Attachment:

File Name: limesurvey... (1).lss
File Size:58 KB


One last word.
Do you really think to show the survey like this?
All on one page and with numeric entry fields of full length?
 

Tot ziens
Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Attachments:
The following user(s) said Thank You: mbraun

Please Log in to join the conversation.

More
2 months 17 hours ago #220586 by mbraun
Hi Joffm,

Thank you for your work and time! I really appreciate it and you really helped me so much already.

I imported your survey and the result still is displayed as NAN as soon as one or more zeros are put in, unfortunately. We expect most users to put in a zero for at least one of the questions, so that's a bit of a pity. I assume this is the case because the other question (IPAQ2, 4 or 6) do not get posed if their equivalent is 0? But haven't found a way to get around this. However, this is not really an issue for us as long as the conditions still work normally since we can easily calculate it ourselves afterwards.

The other values do seem to get saved, but only if I keep the question IPAQ Resultaat unhidden. I now moved the equation back to the equation field and put some generic text as question in order to make it look ok for participants. I'm ok with this solution I think, but there must be a more elegant way? I thought the entire idea of the equation function was that it could remain hidden to be honest..

About your last comment: I didn't occupy myself with the aesthetics of it much (yet) ;) But it will probably stay on one page

Please Log in to join the conversation.

More
2 months 15 hours ago - 2 months 15 hours ago #220599 by Joffm
Sorry, I did not check the answer table, after I got the correct result in the equation.

Well, so we just have to check it.
If IFAQ1>0 then add the multiplication, otherwise add 0.
So change the equation to
{sum(if(IPAQ1>0,IPAQ1.NAOK * IPAQ2.NAOK * 8,0),if(IPAQ3>0,IPAQ3.NAOK * IPAQ4.NAOK * 4,0),if(IPAQ5>0,IPAQ5.NAOK * IPAQ6.NAOK * 3.3,0))}

Here the answer table with the NANs, but in the last row there is the result though there is a "0" in IFAQ5
 

Joffm

And as you say: equations usually are hidden - and the work always.


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Attachments:
Last edit: 2 months 15 hours ago by Joffm.
The following user(s) said Thank You: mbraun

Please Log in to join the conversation.

More
1 month 4 weeks ago #220645 by mbraun
I cannot thank you enough! Really appreciate the help. It works perfectly

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now