Search code examples
qualtrics

Qualtrics.SurveyEngine.addOnload runs twice in preview mode in Qualtrics survey software


Whenever I try to test a Qualtrics survey in preview mode, Qualtrics.SurveyEngine.addOnload will be called twice. This is not a problem for conditional events (as in most of the examples), but a large problem for unconditional code a timed page change (this will be triggered twice as well). See the following snippet:

Qualtrics.SurveyEngine.addOnload(function()
{
     $('NextButton') && $('NextButton').hide();
     var that = this;
     var timeOutInterval=1000+Math.trunc(Math.random()*10000);
     alert(timeOutInterval); //for Testing only
     var myVar;
     myVar = setTimeout(function(){ that.clickNextButton();}, timeOutInterval);
});

If I launch the survey, this will lead to a page change after 1-11 seconds. If I preview the survey, this change will happen as well, followed by a second change. The alert will be shown twice as well.

Does anyone have a solution, how this functionality could be tested in preview mode?


Solution

  • I've run into Survey Preview issues with JFE as well. There are ways to get around JFE mode and preview in non-JFE mode.

    If only care about a specific set of questions in a block and don't care about the survey flow, the easiest solution is to use View Block. It does not use JFE. Go to the Block drop down and choose View Block.

    If you need to preview the whole survey, there are tricks to 'break' JFE and force it to non-JFE mode. These tricks seem to be a moving target as Qualtrics makes changes. The best one (easiest) I've found that is working for me today on my Qualtrics account (notice all the qualifiers) is to add an end of survey object to the survey flow, click custom, and check the "Override Survey Options" box.

    If that doesn't work, I've found that once a survey gets over a certain size, it doesn't use JFE mode anymore. I don't know what the limit is, but if you add a bunch of fake questions after your end of survey you can trick it that way as well.