set a automatically timer | XM Community
Skip to main content

hi,
Hi! We want to complete a design in the experiment. Specifically, we want to show participants a group of words (60 words in total), one page for each word, and participants can click on the next page to see the next word. In the process, they need to see a timer (the time is 1 minute). In the process of clicking on words, the timer counts down or counts up. We now encounter a difficulty: We design each word in a question, and all the words are in a block. We hope that this timer can only be displayed in the block, that is, at the end of 1 minute, it will automatically jump to the next block. If the participant reads all the words in less than one minute, he will wait for the end of the one-minute timer before jumping to the next block. At the same time, the timer should be eye-catching enough. 
At present, the difficulties we encounter are:
How to automatically jump to the next block after one minute


Qualtrics.SurveyEngine.addOnload(function()

{

var that = this;

/*Place your JavaScript here to run when the page loads*/

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: 00:30"; 

header.appendChild(timer);

document.body.insertBefore(header, document.body.firstChild);

function startTimer(duration, display) { 

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';

  displayttext] = minutes + ":" + seconds; 

  if (--timer < 0) { 

clearInterval(myTimer); 

  timeOver(); 



}, 1000); 



 var timerSeconds = 30, 

 display = document.querySelector('#time'); 

 startTimer(timerSeconds, display); 

 var timeOver = function() { 

document.getElementById("timer_1").innerHTML = "Time is up."; 
Qualtrics.SurveyEngine.setEmbeddedData("blockTimeFlag", "1");  
$('NextButton').click();

 } 



});



Qualtrics.SurveyEngine.addOnReady(function()

{

/*Place your JavaScript here to run when the page is fully displayed*/



});



Qualtrics.SurveyEngine.addOnUnload(function()

{

/*Place your JavaScript here to run when the page is unloaded*/

clearInterval(myTimer); 

Thank you for your help!

We have the same problem, is there any way to solve that problem?


Leave a Reply