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
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.
Thanks so much, Tom! It worked. Such a simple solution that it's kind of embarrassing. Ha. I appreciate it. Have a great weekend!
Hi, I was trying to do the exact same thing, but could not get it to work at all. I put
start = ${e://Field/Q_TotalDuration}
in before the block in Survey flow as "embedded data" and then I put
duration = $e{ e://Field/Q_TotalDuration - e://Field/start }
in survey flow after the block.
The issue is that when I export the data, the time is not being recorded/reported in these fields. Is there something I am doing wrong or is there a setting I need to make? Please help as soon as possible because this is sort of urgent!
https://community.qualtrics.com/XMcommunity/discussion/comment/27957#Comment_27957TomG This sounds like exactly what I'm looking for but how do you add it to the 'survey flow before the block'? Apologies - a Qualtrics novice!
https://community.qualtrics.com/XMcommunity/discussion/comment/36644#Comment_36644Hi Berthiaume , did you create two embedded variables start and duration.
Did you pass ${e://Field/Q_TotalDuration} as value of start embedded field before block and $e{e://Field/Q_TotalDuration - e://Field/start} as a value of duration after the same block?
Please follow the same way and if that issue will still persist then please share the screenshot.
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.