Welcome to the LimeSurvey Community Forum

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

Conditions and values

  • exlibris139
  • exlibris139's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
9 years 1 month ago #116786 by exlibris139
Conditions and values was created by exlibris139
Are answers the only thing conditions can depend upon? Could they be made work with the timestamps that are recorded?

The scenario I'm envisioning is a group of questions, where if the total time elapsed for the group exceeds a certain amount, the remaining questions are skipped and the user jumps to the next group.
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 1 month ago #116801 by holch
Replied by holch on topic Conditions and values
I don't think that you can access the timestamps via expression manager, but if you could, you still would need a timer. So why not just putting up a timer and count down from the moment they access the question group and then forward? Not sure why you need to access the timestamp? Or are the questions of the group not on the same page?

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
More
9 years 1 month ago - 9 years 1 month ago #116805 by Bigred01
Replied by Bigred01 on topic Conditions and values
Take a look at setTimeout or setInterval javascript functions.

Here is an example of some code that will click the next button after 10 seconds.
Code:
<script>
$(document).ready(function() {
 
   timeOut = setTimeout(function() {
      $('#movenextbtn').trigger('click');
   },10000);
 
});
</script>

You can adjust the 10000 to change when it will fire (its in milliseconds).

You could start with this and adapt it to what you need. If the questions are set to mandatory and this fires, the page will just reload. You can either go by the honor system and have them not mandatory, or add more code that takes care of mandatory logic when someone attempts to press next before the timer goes off.

Some added mandatory logic could look something like this. (this is for a group that contains both radios and checkboxes).
Code:
<script>
$(document).ready(function () {
    var stopNext = true;
    timeOut = setTimeout(function () {
        stopNext = false;
        $('#movenextbtn').trigger('click');
    }, 10000);
 
    $('#movenextbtn').click(function (e) {
        if (stopNext) {
            var radioCount = $('.list-radio').length,
                radioChecked = $('.list-radio :checked').length,
                checkCount = $('.multiple-opt').length,
                checkChecked = $('.multiple-opt :checked').length;
 
            if ((radioCount != radioChecked) || (checkCount != checkChecked)) {
                e.preventDefault();
                alert('Please answer all questions to continue');
            }
        }
    });
});
</script>

The above code should (haven't tested it) stop someone from moving next if they haven't answered all of the radio and multiple choice questions on the current page before the timer goes off. If the timer goes off, it will press next and the mandatory logic wont run.

Hopefully this is a good starting point for you. You can even add a hidden question and answer it if the timer goes off so you can tell in the results easily if someone didn't answer the group in time.

*EDIT: missed a couple words
Last edit: 9 years 1 month ago by Bigred01.
The topic has been locked.
More
9 years 1 month ago #116806 by Bigred01
Replied by Bigred01 on topic Conditions and values
Please ignore the "timeOut =" in the code. I was going to a clearTimeout() but removed it. Missed this in both examples. (not able to edit the post anymore)
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 1 month ago #116814 by tpartner
Replied by tpartner on topic Conditions and values
You could use the built-in Time Limit function placed on a text-display question in the group. Of course, you would still have problems with any unanswered mandatory questions.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • exlibris139
  • exlibris139's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
9 years 1 month ago #116869 by exlibris139
Replied by exlibris139 on topic Conditions and values
Thank you all for your help. Holch hit on the issue that the questions are displayed separately and not in their group.
Bigred, I'll be messing around with your solution today, thank you for the comprehensive suggestion!
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose