Welcome to the LimeSurvey Community Forum

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

Default answer not picking update a previous answers

More
6 years 11 months ago #151836 by C123
I have a question that has a default answer that depends on the answer given earlier in the survey. However, this does not pull through. Here is the statement I'm using;

if(is_empty(DP1Q1), 'This question has not been answered', 'This question has been answered')


The odd thing is if I put the same statement in the question body it pulls through correctly. So the question body says that they have answered the question and the default answer says that they have not. Does anybody have any ideas?

Thanks in advance.
The topic has been locked.
More
6 years 11 months ago #151842 by jelo

C123 wrote: I have a question that has a default answer that depends on the answer given earlier in the survey.

What questiontype should be assigned a default answer.
Assigning a Textstring "This question has not been answered" as a value for a default answer seems not correct.Most common would be an answer or questioncode, but not a written text.

manual.limesurvey.org/Expression_Manager#Access_to_Variables

Export these two questions as a survey and attach it here.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
More
6 years 11 months ago - 6 years 11 months ago #151844 by C123
Hi

Thanks for reading I've attached the two questions.

It is a work in progress and the text will be different once it finished, I'm just trying to get the basic mechanics working at the moment.

I did try using question codes but I get a similar error where the default answer is blank but if I use the code in the question body it works.
Last edit: 6 years 11 months ago by C123. Reason: Wrong file
The topic has been locked.
More
6 years 11 months ago #151855 by jelo
What version of LimeSurvey is used? Since you use a textfield you can assign text the way you do it.
Code:
{if(is_empty(DP1Q100),'This question has not been answered','This question has been answered')}



It's working. I only edited the textfield, but didn't change anything. The DP1Q1 is your post was DP1Q100 in your export. So no change by me. Perhaps you try again and check every variable. Perhaps you fixed it already.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
More
6 years 11 months ago #151857 by C123
Hi

Thanks for having look, I'll have to investigate further as I still get the error when I select an answer (see below)

Attachments:
The topic has been locked.
More
6 years 11 months ago #151866 by jelo
That is no error, the default answer will not change dynamically once you got the answer shown.
You might consider placing the answer on another page. That might will update the default answer.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
More
6 years 11 months ago #151869 by C123
I should have mentioned that they these are in different groups it is set to show a group a page. However, I have got full jumping turned on would that make a difference?
The topic has been locked.
More
6 years 11 months ago #151873 by jelo

C123 wrote: However, I have got full jumping turned on would that make a difference?

Fulljumping? I don't understand.

The default answer can only be set once, when the question is displayed.

Best approach using Limesurvey is using Group by Group mode.
Place the question in one group and the text question with the default answer expression in the next group. The default answer will be shown correctly.

If not, export a survey structure instead of single questions files.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The following user(s) said Thank You: C123
The topic has been locked.
More
6 years 11 months ago #151889 by C123
Thanks, for your help I think I understand now, even though I'm using the group by group mode because I've got full navigation turned on once the group with the default answer group is visited it won't change even if the user goes back and changes the other answer.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 11 months ago #151900 by tpartner
It sounds to me that in order to have this dynamic, rather than using the default answer setting, you should be using an equation question with the Expression Manager assignment operator to set the question.

Some notes:

1) The equation question is best placed in a group following that of the question to be manipulated.
2) The equation question must be place in a group that will always be seen (not skipped via relevance).

manual.limesurvey.org/Expression_Manager#Operators

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
6 years 11 months ago #151906 by jelo

C123 wrote: it won't change even if the user goes back and changes the other answer.

Correct, that is intended behavior (at least it works like this since default answers were introduced). Post a small export of two groups here. We can try the assignment as tpartner suggested.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose