2

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?

jank
  • 665
  • 6
  • 14
  • 1
    Is preview in "jfe" (...qualtrics.com/jfe/preview/SV_...) or "non-jfe" (...qualtrics.com/SE/?SID=SV_...) mode? The problem with "jfe" mode is that it doesn't exactly mimic regular "non-jfe" mode. I'm guessing this is a "jfe" issue. – T. Gibbons Mar 20 '15 at 12:11
  • the preview page is: (...jfe.qualtrics.com/preview/SV_). This uses the Javascript Form Engine (JFE), indeed. After launch the page has the "SE"-form. My problem is: there is no way to change the preview mode into any other format. It is nice to see the mobile version displayed, but I would prefer to be able to have a non-breaking test... – jank Mar 20 '15 at 15:06

3 Answers3

3

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.

T. Gibbons
  • 4,919
  • 2
  • 15
  • 32
  • 1
    Interestingly I was told by support that it isn't a survey length issue, but rather a lack of support for certain question types. I was told that this is being worked on and will not be the case soon. – Anthony Rivas Mar 20 '15 at 16:28
  • Choosing the end of survey block with "override survey options" (and no further checkmarks) did the trick for me. The code runs correctly now (while I am deprived of the mobile preview that I can check later). I have not tried the question lists or other question types. – jank Mar 20 '15 at 21:04
2

Qualtrics links jQuery as of current writing (albeit the shorthand $ is reserved for the prototype.js library).

Following should skip execution of addOnload javascript in the mobile preview:

Qualtrics.SurveyEngine.addOnload(function()
{
    if(jQuery(this.questionContainer).parents('.MobilePreviewFrame').length)
    {
        console.log('Mobile Preview - skipping rest of addOnload');
        return true;
    };
    console.log("Running addOnload()");

   // The rest of your code. Log statements can obviously be removed
});

Hope this is helpful

PeterR
  • 432
  • 2
  • 7
2

It seems Qualtrics now defaults to JFE mode for live surveys as well. We have been able to resolve this by adding the query string &Q_JFE=0 to the end of our survey URLs, like so:

https://uleidenss.eu.qualtrics.com/SE/?SID=SV_123432434343&Q_JFE=0

This had the additional benefit of solving our issue with JFE mode breaking several of our long time running Qualtrics JQuery experiments.

  • 1
    Good tip! Unfortunately disabling JFE disables mobile compatibility. In many cases mobile is now the majority of respondents. Another solution is to update scripts to account for JFE. JFE mode can be detected as shown in this snippet: https://gist.github.com/marketinview/f0fc1d81981161388917. Here is an example snippet of it in use: https://gist.github.com/marketinview/cd5d385d8803124078a0 – T. Gibbons Nov 12 '15 at 19:28
  • This solution still works for me (mobile compatibility is not desired). It seems a strange design decision to break any les superficial use of javascript. I am similarly wondering about the need to insert most of my functions into the "Look & Feel"-Advanced Section... The View Block - method still works without JFE, but setting embedded variables again requires the full survey... – jank Mar 22 '16 at 03:13