Welcome to the LimeSurvey Community Forum

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

Is there a way to force a skipped question to store default value in response DB

More
2 weeks 6 days ago #273645 by rwinford77
Please help us help you and fill where relevant:
Your LimeSurvey version: LimeSurvey Community Edition Version 6.16.2+251209 
Own server or LimeSurvey hosting:  own
Survey theme/template:  bootstrap vanilla (with some color mods)
==================

Hello LimeSurvey community.  thanks for all the help in the past.  I understand all of you are volunteers and I greatly appreciate your help.  

I am trying to use values from the participation token file to reduce the amount of typing the participants have to do.  I can successfully retrieve the TOKEN attribute data and display to the user.  It is information that they entered previously, such as their region or area. I set the default answer for the questions from the TOKEN attributes.  I show them the data and then have a check-box asking if they need to update the data.  If the check-box (multiple choice with one possible answer) is checked, I show the questions to update the personal data.  If the box is NOT checked, I do not display the questions (relevance 0).  If the personal info questions are NOT shown, then nothing is stored in the response DB, even though there was a default answer set.  

I have created a work-around by creating a hidden equation question at the end that sets the value: 
Code:
(if(is_empty(Q00.NAOK), TOKEN:ATTRIBUTE_1, Q00.NAOK)}]

Is there a way to "force" LS to save the response of a non-displayed question (relevance 0) to be the default value?

I've attached a simple LSS file that I believe shows the issue.

thanks,
Rick
 

Please Log in to join the conversation.

More
2 weeks 6 days ago #273647 by Joffm
Hi,
well, this is the desired and expected behaviour.
If a question is skipped, there is a reason for this. So the question is emptied.
Possible scenario:
The respondent clicks "My car is a Honda" and he is asked some questions about "Honda"
Then he realises that there was a mistake. He wanted to click "Hyundai". So he returns to this page and changes the selection to "Hyundai".
Of course his answers to the "Honda" questions have to be removed.

Now your scenario:
I remember that some years ago I showed something about this.
But anyway: You should revise this workflow.
I'd simply show the text and in the question I'd say "These are the informations you entered in the previous wave. If there are any changes, please enter ".

Joffm

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

Please Log in to join the conversation.

More
2 weeks 6 days ago #273648 by rwinford77
Hi Joffm, thanks for the quick reply.

That's actually what I do: I show the users the previous answers and ask if they need/want to update. If they say no (not check the box) then the survey assumes the same answers and does not show the questions. But, then there are no answers in the response file for those questions.

Rick

Please Log in to join the conversation.

More
2 weeks 6 days ago #273651 by Joffm
Yes, I know.
And in my opinion this is an unnecessary doubling.
Therefore, either
1. use a simple text question (as I said before)
2. use an array(text) with two columns (one with the text, one to indicate the need to change); some JavaScript needed.
3. You may hide the question by JavaScript.

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

Please Log in to join the conversation.

More
2 weeks 6 days ago - 2 weeks 6 days ago #273652 by rwinford77
Thanks again for your quick response; I do appreciate it.

I was hoping for a different answer, but I understand the need to keep answers empty if the question is not shown. My personal info answer is 4 different questions of different types (text, multiple-choice, and list-dropdown). So, I will use my current workaround: I have created 4 hidden equation questions at the end: if Q is empty, use token:attribute, else use Q. Then, that equation Q answer is stored in the response and I will use that in post processing.

thanks again.
Last edit: 2 weeks 6 days ago by rwinford77.

Please Log in to join the conversation.

More
2 weeks 5 days ago #273657 by Joffm
Hi,
as I said, you have to use a different approach.
Here I show two solutions:

1. This first only uses some css, the classes "no-question, no-bottom and "disable-irrelevant"
Put them into your "custom.css"
Code:
.disable-irrelevant.ls-irrelevant.ls-hidden {
   display:block;
}
.disable-irrelevant.ls-irrelevant .form-control {
   background-color: #eee;
   cursor: not-allowed;
}
 
.no-question {
    border-top:0;
    margin-top: -5px;
}
.no-question .question-title-container,
.no-question .question-valid-container {
    display:none;
}
.no-bottom {
    border-bottom:0;
    margin-bottom:0;
}
.no-question .answer-container {
    padding-top: 0em;
    padding-bottom: 0.5em;
}    
.no-question .question-container {
    border: none !important;
    margin-top: -10px !important;
}    
.no-bottom .answer-container {
    padding-bottom: 0em;
}

First question (Q1a) - the text question gets the css classes "no-bottom disable-irrelevant"
Second question (Q1) - the bootstrap button gets the css class "no-question"
Furthermore the first question has the condition "Q1==1"
You may use one button or two


You see the text field initially is set to "disabled"
If you click "Update needed" the field changes to "editable"


2. This second uses javascript to hide the second question (here the second question is the text question)
and also the css classes "no-question" and "no-bottom"
Code:
<script type="text/javascript" charset="utf-8">
    $(document).on('ready pjax:scriptcomplete',function(){
 
        // Identify this question
        var thisQuestion = $('#question{QID}');
        var nextQuestion = $(thisQuestion).nextAll('.text-short:eq(0)');
        $(nextQuestion).hide();
        
        // Listeners on the radios
        $('input:radio', thisQuestion).on('click', function(e) {
            var thisIndex = $(this).closest('.answer-item').index();
            if(thisIndex<1) {
                   $(nextQuestion).show();
            }  
        });
    });
</script>

 
The click on the first button shows the text.



At the last remark: The value of the TOKEN:ATTRIBUTE is set in the default answer of the text questions.
Group G0 and question QSet is only necessary if you use the second solution.

 

File Attachment:

File Name: limesurvey...1692.lss
File Size:71.1 KB

Unfortunately you did not mention so far that you use other question types.

Joffm

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

Please Log in to join the conversation.

More
2 weeks 5 days ago #273660 by Joffm
Sorry, 
I found a copy/paste error in Q2a. There is the condition Q2==1. This has to be removed.

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

Please Log in to join the conversation.

More
11 hours 29 minutes ago #273765 by rwinford77
@Joffm Thank you very much for your suggestions and code. I have learned quite a bit, and I'm using some of the css you wrote. Unfortunately, I can't use the javascript (company policy) because I'm the only one who can read it, write it, and maintain it. It's not the optimal way, but I am using hidden equation questions a the end to save the values I need.

apologies for the late reply; too many deadlines at the beginning of the year.

I am totally grateful for all the time & effort you volunteers put into this; it's been so helpful.

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose