JS Timer no longer works properly when the next button is pressed simultaneously when the time is up | XM Community
Solved

JS Timer no longer works properly when the next button is pressed simultaneously when the time is up


In my survey, participants auto progress to the next block when a specified time limit (1 minute) has been reached for the previous block. I used the script suggested in the following link and made the adjustments that were discussed in the answer: https://stackoverflow.com/questions/45703003/qualtrics-progress-to-next-block-when-time-is-up?rq=1
The timer is displayed correctly and participants are auto progressed to the next block when the time is up in the current block. However, when participants simultaneously hit the next button when time is up (Time Remaining: 00:00), the auto progress function no longer works properly. In this case, participants move on to the next question in the current block and are able to answer all questions in this block. This is a huge problem in my survey. Participants should only be able to see the questions, which they are able to answer within the given time.
 Do you have any suggestions for my problem? Any help is appreciated.
 Here is my script: 
Screen Shot 2020-05-14 at 10.59.24.pngI also initialized an embedded data field in the survey flow before the block: blockTImeFlag = 0
And I added the following display logic to my questions in the block: if blockTimeFlag = 0
 

icon

Best answer by SarahAndrea 15 May 2020, 08:47

View original

4 replies

Userlevel 7
Badge +27

Try moving 'if(--timer < 0) ...' to the beginning of the setInterval function and hide the NextButton in the first line of the if.

Thank you for your reply TomG . I tried to implement your suggestions as follows.
Screen Shot 2020-05-14 at 18.44.29.pngHowever, when I simultaneously hit the next button and time is up, I still have the same problem. Did I incorrectly hide the next button? When I tried it, the next button was still visible when time was at 00:01 or 00:00.  

Userlevel 7
Badge +27

You can try changing the condition to --timer < 1.

Changing the condition to --timer < 1 only reduced the timer to be up after 59 seconds and to auto progress. This still did not solve my problem. Now, when you simultaneously press the next button after 59 seconds, the same issue occurs.
However, your previous suggestion to hide the NextButton got me thinking and I stumbled across the following JS in the community and adjusted it to my setting.
Screen Shot 2020-05-15 at 08.33.04.pngThis hides the next button after 1 minute. And since the timer starts counting one second late (so technically it’d be 1 minute and 1 second), 1 second before time is up, the next button is hidden. As far as I can tell right now, this workaround solves my problem since the next button can no longer be pressed at the same time as time is up. Thank you for very much for your support! 

Leave a Reply