Solved
Javascript Timing: Timing incorrect on subsequent timed blocks
I have a kind of complicated survey flow (attached), with six different places in which the Next button is hidden from participants until the time elapses. These six places are organised into 3 groups/blocks, with each group/block comprising of two timed pages (+2 other pages). One page is timed for 150 seconds, and the other page is timed for 60 seconds.
I am using Javascript to time each page, as I have heard that there can be issues with the built-in Qualtrics timer.
The first two pages (in one group/block) are timed correctly. That is, the time I specify in the Javascript is the time that elapses when I preview the survey (timing manually with a stopwatch from when the page loads to when the Next button appears). However, for the four pages after this, the time I specify in the Javascript does not match the time that actually elapses. For example, the Javascript specifies 150 seconds, but only 10 seconds will actually pass before the Next button appears. The exact time that passes between the page loading and the Next button appearing seems to be variable (e.g., sometimes 30 seconds, sometimes 10, sometimes 3), so I can't just add on extra time to the Javascript to match what I want.
Here is one script I am using (on 3 of the pages):
> Qualtrics.SurveyEngine.addOnload(function()
> {
> /*Place your JavaScript here to run when the page loads*/
>
> });
>
> Qualtrics.SurveyEngine.addOnReady(function()
> {
> var displayTime = 150;
> if($('NextButton'))$('NextButton').hide();
> new PeriodicalExecuter(function(){
> if($('NextButton')){$('NextButton').show();$('NextButton');}
> },displayTime);
>
> });
>
> Qualtrics.SurveyEngine.addOnUnload(function()
> {
> /*Place your JavaScript here to run when the page is unloaded*/
>
> });
Here is the other script I am using (on the other 3 pages):
> Qualtrics.SurveyEngine.addOnload(function()
> {
> /*Place your JavaScript here to run when the page loads*/
>
> });
>
> Qualtrics.SurveyEngine.addOnReady(function()
> {
> var displayTime = 60;
> if($('NextButton'))$('NextButton').hide();
> new PeriodicalExecuter(function(){
> if($('NextButton')){$('NextButton').show();$('NextButton');}
> },displayTime);
>
> });
>
> Qualtrics.SurveyEngine.addOnUnload(function()
> {
> /*Place your JavaScript here to run when the page is unloaded*/
>
> });
I have already checked that the scripts are identical across all of the pages, so that can't be it.
Does anyone have any idea why this might be happening and/or what I can do to fix it?
Best answer by Rachel
To anyone who is also looking for an answer to this question, I think I found a solution. I changed every instance of the code to what is below, and it seems to be working perfectly.
> Qualtrics.SurveyEngine.addOnload(function()
> {
> this.hideNextButton();
> this.showNextButton.delay(150);
>
> });
>
> Qualtrics.SurveyEngine.addOnReady(function()
> {
> /*Place your JavaScript here to run when the page is fully displayed*/
>
> });
>
> Qualtrics.SurveyEngine.addOnUnload(function()
> {
> /*Place your JavaScript here to run when the page is unloaded*/
>
> });
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
