My friend wrote me some really nice code! I asked him to write some javascript code to create a timed test. They start a block of a 100 questions, but when it starts it starts a countdown. When the countdown reaches 0 the script automatically skips to the next question. This happens for all the questions that see that the timer stands at zero. However, with a 100 questions it goes through all the questions so quickly, it looks like it survey is crashing.
Is there a way to adjust this code to skip to a certain question instead if the timer reaches 0? Currently, it reads the script and goes to the next question in line, which then does the same. Is there a way to instead instruct Qualtrics to skip everything and go to my "Post-measure" question?
Qualtrics.SurveyEngine.addOnload(function()
{
function startTimer(duration, display) {
if (--timer < 0) {
clearInterval(myTimer);
timeOver();
}
}
var timerSeconds = parseInt("${e://Field/timeRemaining}");
display = document.querySelector('#time');
if (timerSeconds > 0) {
startTimer(timerSeconds, display);
}
var timeOver = function () {
document.getElementById("timer_1").innerHTML = "Time is up.";
$('NextButton').click();
x = 1;
var bgColor = setInterval(change, 1000);
}
});
Qualtrics.SurveyEngine.addOnReady(function()
{
/*Voer uw JavaScript hier uit wanneer de pagina volledig wordt weergegeven*/
var timerSeconds = parseInt("${e://Field/timeRemaining}");
if (timerSeconds === 0) {
$('NextButton').click();
}
});
Qualtrics.SurveyEngine.addOnUnload(function()
{
/*Voer uw JavaScript hier uit wanneer de pagina nog niet geladen is*/
});
Best answer by TomG
View original