I want to calculate the duration of a block that has multiple pages. For example, one block has 23 questions. Each question shown on a different page. I want to know how long it takes for respondents to get through the block. I do not need for the timer to be visible to participants.
Here's what I have tried:
At the beginning of the block, I capture the time upon load in a hidden question (note: I use hidden questions because of randomization so that I can just randomize all other questions in the block, except for the first and last ones capturing the start and end times):
Qualtrics.SurveyEngine.addOnload(function()
{
jQuery("#"+this.questionId).hide();
var startTime = new Date();
Qualtrics.SurveyEngine.setEmbeddedData( 'startTime', startTime);
this.clickNextButton();
});
At the end of the block, I capture the time again in a hidden question:
Qualtrics.SurveyEngine.addOnload(function()
{
jQuery("#"+this.questionId).hide();
var endTime = new Date();
Qualtrics.SurveyEngine.setEmbeddedData( 'endTime', endTime);
this.clickNextButton();
});
In the next block, I want to calculate the duration and display to the respondent. I have tried using JS with the variables above and with the embedded data, like this:
Qualtrics.SurveyEngine.addOnload(function()
{
var duration = (endTime.getTime() - startTime.getTime()) / 1000;
Qualtrics.SurveyEngine.setEmbeddedData( 'duration', duration);
});
and
Qualtrics.SurveyEngine.addOnload(function()
{
var duration = ("${e://Field/endTime}".getTime() - "${e://Field/startTime}".getTime()) / 1000;
Qualtrics.SurveyEngine.setEmbeddedData( 'duration', duration);
});
I have even just tried doing a Qualtrics equation $e{ ( e://Field/endTime - e://Field/startTime ) / 1000 }. But it's not working, any help? I'm open to trying a completely different method altogether, too.
Thanks,
Josh
Solved
Duration of a block with multiple pages
Best answer by TomG
In the survey flow before the block:
start = ${e://Field/Q_TotalDuration}
In the survey flow after the block:
duration = $e{ e://Field/Q_TotalDuration - e://Field/start }
To display the duration in the next block, pipe duration:
${e://Field/duration}
No JS or hidden questions needed.
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.