Hi all!
I am trying to implement the following: I have several questions within a block displayed with "break page". The respondent has 2 minutes to answer all the questions within the block. The problem is that I cannot take advantage of the Auto Advance Timing question which sets the max time you can spend in a block since I am using "break page" for each question in the block.
I tried to include a Javascript according to the following link: https://stackoverflow.com/questions/47317718/how-to-use-automatically-move-respondents-in-qualtrics-with-global-timer-for-blo. but it seems not to work properly.
This is the code I pasted in the first question of the block:
Qualtrics.SurveyEngine.addOnload(function()
{
var header = document.createElement("div");
header.className = "header"
header.id = "header_1";
var timer = document.createElement("div");
timer.className = "timer";
timer.id = "timer_1";
timer.innerHTML = "Time Remaining: 02:00";
header.appendChild(timer);
document.body.insertBefore(header, document.body.firstChild);
function startTimer(duration, display) {
Qualtrics.SurveyEngine.setEmbeddedData('timeRemaining', timer);
var timer = duration, minutes, seconds;
var myTimer = setInterval(function() {
minutes = parseInt(timer / 60, 10)
seconds = parseInt(timer % 60, 10);
minutes = minutes < 10 ? "0" + minutes : minutes;
seconds = seconds < 10 ? "0" + seconds : seconds;
var text = ('innerText' in display)? 'innerText' : 'textContent';
displayltext] = minutes + ":" + seconds;
if (--timer < 0) {
clearInterval(myTimer);
timeOver();
}
}, 1000);
}
var timerSeconds = parseInt("${e://Field/timeRemaining}"),
display = document.querySelector('#time');
startTimer(timerSeconds, display);
var timeOver = function() {
document.getElementById("timer_1").innerHTML = "Time is up.";
x = 1;
var bgColor = setInterval(change, 1000);
$('NextButton').click();
}
});
What am I missing ?
Thank you very much in advance!
Be the first to reply!
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.