I have a block with 20 questions.
After 4 minutes, I'd like for participants to move on to the next block (regardless of how many questions they saw in the current block).
To achieve this, I was able to use code from here: https://stackoverflow.com/questions/47317718/how-to-use-automatically-move-respondents-in-qualtrics-with-global-timer-for-blo to automate the process.
The problem is that the code I used displays a countdown to the participants. I don't want participants to know the time remaining. When I try to remove bits of the code that display the timer to participants, the code breaks down.
Here's the code I am currently using. Note: I have an embedded variable called "timeRemaining" and for each subsequent question in the same block, I have a display logic that is set to "if timeRemaining > 0"
!
Which lines/ bits do you think I can remove to avoid displaying the counter/timer to participants? Alternatively, can you provide a code that autoadvances to the next block when a timer is up without displaying the timer to participants?
Thank you!
Qualtrics.SurveyEngine.addOnload(function()
{
function startTimer(duration) {
var timer = duration;
var myTimer = setInterval(function() {
Qualtrics.SurveyEngine.setEmbeddedData('timeRemaining', timer);
if (--timer < 0) {
clearInterval(myTimer);
timeOver();
}
}, 1000);
}
var timerSeconds = parseInt("${e://Field/timeRemaining}");
startTimer(timerSeconds);
var timeOver = function() {
$('NextButton').click();
}
});
https://www.qualtrics.com/community/discussion/comment/22621#Comment_22621This was really helpful for me.
I adapted the code slightly to put the cursor in the box automatically and require 'enter' to advance rather than press the next button. I thought it was working perfectly but when I added the next block that also timed out straight away... what am I doing wrong?
I don't know much about JS so any help appreciated. Here's the code:
Qualtrics.SurveyEngine.addOnload(function()
{
function startTimer(duration) {
var timer = duration;
var myTimer = setInterval(function() {
Qualtrics.SurveyEngine.setEmbeddedData('timeRemaining', timer);
if (--timer <= 0) {
clearInterval(myTimer);
timeOver();
}
}, 1000);
}
var timerSeconds = parseInt("${e://Field/timeRemaining}");
startTimer(timerSeconds);
var timeOver = function() {
$('NextButton').click();
}
});
Qualtrics.SurveyEngine.addOnReady(function()
{
$('NextButton').hide();
if($('PreviousButton')) $('PreviousButton').hide();
var inputText = $(this.questionId).down('.InputText');
var evt = inputText.on('keydown', function(e) {
if(e.which == 13) {
evt.stop();
$('NextButton').click();
}
});
inputText.activate();
});
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.