Welcome to the LimeSurvey Community Forum

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

Moving automatically to next bquestion

More
10 years 1 month ago #122841 by jake1729
Is there a way to get this to work on just a single group of questions (instead of using it in the template.js)? I have a series of radio type questions in a single group that I want the user to be able to automatically advance to next question?

Whereas, I have other parts of the survey with radios that I do NOT want this behavior to apply.

Thanks.
The topic has been locked.
More
10 years 1 month ago #122845 by tpartner
To trigger Next/Submit in individual list-radio questions, add this to the question source:

Code:
<script type="text/javascript" charset="utf-8">    
  $(document).ready(function(){
    $('#question{QID} input[type="radio"]').on('click', function(){
      $('#movenextbtn, #movesubmitbtn').delay(300).click();
    });
  });
</script>

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: jake1729
The topic has been locked.
More
10 years 1 month ago - 10 years 1 month ago #122867 by Bigred01
This is what i am currently using for auto next. Its not perfect but it works. You may have to modify to allow for special situations.

I only allow the auto next if the page loads without any answered radios to allow for them to change their answers without moving next. I also don't want to allow auto next if there are checkboxes or textareas visible after a radio change to allow for relevance to show new questions. It also doesn't forward if you select an other-item on a radio question. Works for radio arrays and basic radios or both mixed.

Just call this on document ready and it should be pretty set it & forget it unless you run into a scenario missing.
Code:
function autoForward() {
    var timeOut = '';
    if($('.radio').length > 0 &amp;&amp; $('.radio:checked').length === 0) {
 
        var totalQuestions = $('div.list-radio:visible').length + $('tr.radio-list:visible').length;
 
        $('.radio').on('change', function () {
            clearTimeout(timeOut);
            if ($('.radio:checked').length === totalQuestions &amp;&amp; 
                !$(this).closest('.answer-item').hasClass('other-item') &amp;&amp; 
                $('textarea:visible').length === 0 &amp;&amp; 
                $('.checkbox:visible').length === 0) {
 
                timeOut = setTimeout(function () {              
                    $('#movenextbtn').click();
                }, 500);
 
            }
        });
    }
}

*edit = was missing a :visible
Last edit: 10 years 1 month ago by Bigred01.
The following user(s) said Thank You: jake1729
The topic has been locked.
More
10 years 1 month ago #123055 by jake1729
This is works great. My last question is is there a way to make the recording of responses faster. Right now, there is a slight delay after the user gives an answer and it advances to the next question.

I am trying to mimic the behavior on this survey: hexaco.org/questionnaire_choose_version (click "Start Questionnaire"). As you give your response to each question, it advances to the next question with no delay.

I am thinking this might be along the lines of AJAX, but I really have no idea.

Thank you again.
The topic has been locked.
More
10 years 1 month ago #123056 by Bigred01
You can adjust the delay on the timeout function (right now its 500) for a faster submit.

You wont get that kind of experience with a page by page survey though since the form is submitting and the page reloading every time. Their survey has all of their questions loaded on one page but they only show them to you one at a time. When you answer one of their questions, they hide that one and show the next.
The topic has been locked.
More
10 years 1 month ago #123057 by jake1729
Thank you. So I guess that was my question - there's no way to implement this behavior in Limesurvey?
The topic has been locked.
More
10 years 1 month ago #123058 by Bigred01
No, its pretty easy to make something that's acts like this but it wont have the ajax responses table update. The answers wont be saved until they answer the final question and submit the survey. Will there just be radio and radio-array questions in this survey?
The topic has been locked.
More
10 years 1 month ago #123059 by jake1729
Yes, that's it. Only (List) radio questions. Each question will have the same set of 5 possible answers.
The topic has been locked.
More
10 years 1 month ago - 10 years 1 month ago #123060 by Bigred01
Try calling the script below. In order for this to work, all of your radio questions must be in the same group and all on the same page. Ex. Survey in group by group with 1 group that contains all of your radio questions set to mandatory.
Code:
    $(document).ready(function() {
        $('.mandatory').not('.mandatory:eq(0)').hide();
        var questionTotal = $('.mandatory').length,
            answeredTotal = 0;
        $('.radio').on('change',function() {
            var visibleQ = $('.mandatory:visible');          
            if(visibleQ.find('.radio:checked').length > 0) {
                answeredTotal++;
                visibleQ.hide().next('.mandatory').show();
            }
            if(questionTotal === answeredTotal) {
               $('#movesubmitbtn').click();
            }
        });
    });

*edit - word
Last edit: 10 years 1 month ago by Bigred01.
The topic has been locked.
More
10 years 4 weeks ago #123167 by holch
While I can see why you want to implement that, my own experience and in usability tests is, that when there is no real change on the page, people don't understand what happened, especially when they are not very internet savvy. if the phrases are very similar, people might not notice that something has changed and click the answer given previously without reading.

So make sure that it is obvious to the user that something happened and something changed. A change of a page is pretty obvious a change to the user, here with the quick changes, people struggle sometimes. So some kind of animation (even if small, short and simple) would be good.

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.
The topic has been locked.
More
10 years 4 weeks ago #123170 by tpartner

So some kind of animation (even if small, short and simple) would be good.

Yep ;)

Code:
if(visibleQ.find('.radio:checked').length > 0) {
  answeredTotal++;
  var nextQ = visibleQ.next('.mandatory')
  visibleQ.fadeOut(400, function() {
    nextQ.fadeIn(400);
  });
}

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
10 years 4 weeks ago #123174 by holch
Both scripts work fine in the default template. T-partners code is a nice addition.

Unfortunately doesn't work for my custom template... )-;

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.
The topic has been locked.
More
10 years 4 weeks ago #123177 by Bigred01
This should work unless the question element in question.pstpl has been put into a new container. next() will only find siblings.
The topic has been locked.
More
10 years 4 weeks ago #123214 by holch
Thanks for the reply. This is probably it.

I probably have put a DIV around the question. Because I also have a line separating the questions and when questions are hidden due to conditions, this line still shows (this is a "bug" in my template that I was aware of, but never really went to fix it). It is probably time and this here is additional motivation, because this workaround here can be pretty useful.

But I wanted to use a different base for my template anyway, like the Skeletonquest theme from Dennis or the one from the Dutch guys. But I just didn't have time to look into this yet.

You can spend loads of time with creating templates... ;-)

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.
The topic has been locked.
More
9 years 7 months ago #129694 by bruce78
Thanks to everyone in this thread! The following works for me with Array (radio) and List (dropdown) questions but doesn't work for List (radio), which is fine. I've just pasted the code below into the template.js file for two versions of skeletonquest that I use.

Does anyone see any problems with the javascript below and should it keep on working with new versions of Limesurvey and different themes?
Code:
$(document).ready(function(){
    $(".list-dropdown select").change(function(){
    if($(this).val()!="" &amp;&amp; $(this).val()!="-oth-"){
      $("#movenextbtn,#movesubmitbtn").delay(300).click();
    }
  });
    $('tr.radio-list input.radio').bind('click', function () {      
    var thisArray = $(this).closest('table');
    if($('input.radio:checked', thisArray).length == $('tr.radio-list', thisArray).length) {
      $("#movenextbtn,#movesubmitbtn").delay(300).click();
    }
  });
});
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose