Welcome to the LimeSurvey Community Forum

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

Moving automatically to next bquestion

  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 9 months ago #121508 by tpartner
Replied by tpartner on topic Moving automatically to next bquestion
What LimeSurvey version are you using?

That doesn't look like a copy of an up-to-date template. The limespired template inserts template.js in the <head> element, your template inserts it in the <body>. Please try copying one of the shipped templates.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • aviben
  • aviben's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 9 months ago #121603 by aviben
Replied by aviben on topic Moving automatically to next bquestion
Thanks. It works great for radio type questions. How can I make it work for an array type question?

For each question I create another array with a semantic scale (see attached), a regular array question with a "|" separator

Thanks
The topic has been locked.
  • Mazi
  • Mazi's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
8 years 9 months ago #121604 by Mazi
Replied by Mazi on topic Moving automatically to next bquestion
In general this will be far more difficult for array questions because you need to count the number of items and based on that, auto-redirect once each item was assigned an answer.

In this case, since you only seem to list one item, this may work with some code adjustments.
Maybe Tony can help if you provide a link to an activated sample survey with that question only.

Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 9 months ago #121605 by tpartner
Replied by tpartner on topic Moving automatically to next bquestion
This should work for radio arrays:

Code:
$(document).ready(function(){
 
  $('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();
    }
  });
});

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • aviben
  • aviben's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 9 months ago #121644 by aviben
Replied by aviben on topic Moving automatically to next bquestion
Perfect!!!
The topic has been locked.
More
8 years 7 months ago #122841 by jake1729
Replied by jake1729 on topic Moving automatically to next bquestion
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.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 7 months ago #122845 by tpartner
Replied by tpartner on topic Moving automatically to next bquestion
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
8 years 7 months ago - 8 years 7 months ago #122867 by Bigred01
Replied by Bigred01 on topic Moving automatically to next bquestion
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: 8 years 7 months ago by Bigred01.
The following user(s) said Thank You: jake1729
The topic has been locked.
More
8 years 7 months ago #123055 by jake1729
Replied by jake1729 on topic Moving automatically to next bquestion
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
8 years 7 months ago #123056 by Bigred01
Replied by Bigred01 on topic Moving automatically to next bquestion
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
8 years 7 months ago #123057 by jake1729
Replied by jake1729 on topic Moving automatically to next bquestion
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
8 years 7 months ago #123058 by Bigred01
Replied by Bigred01 on topic Moving automatically to next bquestion
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.

Lime-years ahead

Online-surveys for every purse and purpose