Welcome to the LimeSurvey Community Forum

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

Question B conditioned on time spent on question A

More
10 years 2 months ago #121287 by j_has
I have three questions, A, B, C.

A comes first, then I would like to present B or C, dependent on how much time the respondent spent on question A.

Is there any way to achieve that?

Any help is highly appreciated!
The topic has been locked.
More
10 years 2 months ago #121290 by tpartner
If you are using "group by group" mode, you could put a hidden short-text question ("qHidden") in the same group as Q-A and use a JavaScript timer to record total time in the group. Then simple relevance can be used to control the display of Q-B and Q-C.

Add a script something like this to the source of "qHidden":

Code:
<script type="text/javascript" charset="utf-8">  
  $(document).ready(function(){
 
    // Identify this question
    var thisQuestion = $('#question{QID}');
 
    // Hide this question
    thisQuestion.hide();
 
    // Determine initial elapsed time
    if($('input.text', thisQuestion).val() == '') {
      $('input.text', thisQuestion).val('0.0')
    }
    var elapsed = $('input.text', thisQuestion).val();
 
    // Timer to load this question (1/10 seconds)
    var pageTimer = setInterval(function() {
      elapsed = Number(elapsed) + 0.1;
 
      $('input.text', thisQuestion).val(elapsed.toFixed(1));
 
    }, 100);
 
    // Stop timer when "Next" clicked
    $('#movenextbtn, #movesubmitbtn').bind('click', function () {      
      clearInterval(pageTimer);
    });
  });
</script>

Cheers,
Tony Partner

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

Lime-years ahead

Online-surveys for every purse and purpose