Welcome to the LimeSurvey Community Forum

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

Set Relevance Status using the Expression Manager?

  • AGK925
  • AGK925's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 4 months ago - 8 years 4 months ago #127817 by AGK925
Hello,

I would like to know if it is possible to set the relevance status for a question using expressions in a latter question. I would like to hide a question after it has been answered so that the respondent cannot go back and change their answer, we are conducting a choice survey similar to a choose your own adventure book.

Originally I had the following relevance equation for the first question
Code:
is_empty(Q1.NAOK)
which worked a bit too well. As soon as I answered the question it was hidden; as it should have been. However, I would like the respondent to have the ability to review their answer before continuing to the next page of questions. I would then like to change the Relevance Status of Q1 to 0 at the start of the next page.

I thought I could include the following code to the first question on the next page
Code:
{if(is_empty(Q1.NAOK), Q1.relevanceStatus=1, Q1.relevanceStatus=0)}
but this seems to have no effect on the relevance status of Q1.

Any help would be greatly appreciated,

Tony
Last edit: 8 years 4 months ago by AGK925. Reason: update display of code
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 4 months ago #127874 by tpartner
As far as I know, you cannot directly set relevance with Expression Manager. A workaround may be to have JavaScript toggle a hidden question when you submit the page with Q1. Then set Q1 to only be relevant if the hidden question is unanswered.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • AGK925
  • AGK925's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 4 months ago #127894 by AGK925
Thank you. So if I am understanding your suggestion I should have a hidden question before the first question and the first question should have a relevance equation that is hiddenQ=="". Then using java make an even that sets the answer of the hidden question to the answer of the first visible question which happens when they click the next button? Do you happen to have a link that I could use to reference how to manipulate the hidden question answer based on a radio button selection? Also, when I have tried to manipulate the next/submit button process its seems to erase the answers on that page before moving on, I suspect I am not adding to the stock next/submit buttons functions but rather replacing the stock function with my own. I am using
$('#movenextbtn, #movesubmitbtn').bind('click', function () {
to try and manipulate what the next button does.

Sorry for all of the questions I do not have much experience with Java and Limesurvey. Thank you.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 4 months ago #127896 by tpartner
Oh, wait, I wasn't reading the question correctly. Q1 should still be relevant if answered (it's still a valid answer), you just want to hide it. What type of question is Q1?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • AGK925
  • AGK925's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 4 months ago - 8 years 4 months ago #127897 by AGK925
Q1 is a list(radio) question. I saw the thread below:

Topic: Hide Question if prefilled

and I was trying to manipulate that code to hide if the question once it was answered when the next button was clicked, but i am not experienced enough with Java, I have a lot to learn.

Thanks
Last edit: 8 years 4 months ago by AGK925. Reason: edit url to reference correct post in thread
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 4 months ago - 8 years 4 months ago #127898 by tpartner
Try this in the question source:

Code:
<script type="text/javascript" charset="utf-8">  
  $(document).ready(function() {
    if($('#question{QID} input.radio:checked').length > 0) {
      $('#question{QID}).hide();
    }
  });  
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 8 years 4 months ago by tpartner.
The following user(s) said Thank You: AGK925
The topic has been locked.
  • AGK925
  • AGK925's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 4 months ago - 8 years 4 months ago #127899 by AGK925
Thanks, I that worked great. I thought it might be something simple, but I am still learning.

As a note:

I changed
Code:
$('#question{QID}.hide();
to
Code:
$('#question{QID}').hide();

Just in case anyone finds this thread later.
Last edit: 8 years 4 months ago by AGK925.
The following user(s) said Thank You: levilarsen
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 4 months ago #127900 by tpartner
Oh, yeah, oops...

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose