Question
How to make a delay between pages?
We are writing a test on qualtrics. We want there to be a delay between questions to let participant know if they got the answer correct or incorrect. We are using colors to turn the screen red or blue after they put in the answer and want it to turn back to white on the next page. If anyone can help with coding, that would be very helpful. Right now the explode function and the delay do not work. The code we have is below:
Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
/*focus on the box*/
jQuery("#"+this.questionId+" .InputText").select().focus();
/*Keyboard Press*/
/*word comp logic*/
var bannedWords = ["cat"],
regex = new RegExp('\\\\b' + bannedWords.join("\\\\b|\\\\b") + '\\\\b', 'i');
console.log(regex);
var that = this;
Event.observe(document,'keydown',function(e){
var choiceID = null;
if (e.keyCode == 32) // if space was pressed
{
//var inputs = jQuery(this.getQuestionContainer()).select('input[type="text"]');
// alert(inputs);
jQuery(function () {
jQuery("input").on("change", function () {
var valid = regex.test(this.value);
if (valid)
{
jQuery("body").css("background-color","blue").delay(3000);
choiceID = 1;
//setTimeout(explode, 1000);
jQuery("body").css("background-color","white");
}else{
jQuery("body").css("background-color","red").delay(3000);
choiceID = 1;
window.setTimeout(explode, 1000);
//alert("red");
}
//choiceID = 1;
}); //input.on functin
});
} //end of if statement
}); //event.observe
/*Timer expired function*/
var explode = function(){
if (choiceID==1){
alert("enter explode");
jQuery("body").css("background-color","white");
that.setChoiceValue(choiceID,false);
//that.setChoiceValue(inboxInput,true);
setTimeout(function() {that.clickNextButton();},3600);
alert("boom");
}
};
}); //end of section
Leave a Reply
Rich Text Editor, editor1
Editor toolbars
Press ALT 0 for help
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.