Creating a math distractor task | XM Community
Skip to main content

Is there any way to create a math distractor task like the kind we use in Cognitive Psychology?
I'm looking to create a math task whereby the participants are made to sit through predesigned math arithmetic problems for a preset amount of time (e.g., 30 seconds) that are set within a block, and after the time has past the remainder of the questions will simply not be displayed and the whole block will be skipped on to the next block. At any one point, there should only be one question displayed on the screen at a time, which means I'll have to set up a global timer that times across pages within a block.
Currently I'm using a Javascript with a Display logic that only displays the questions if "TimeLeft is greater than 0". This was done for all questions within the block.
The problem I'm facing right now is that for some reason after the preset time is up (TimeLeft=0), the questions with the display logic is still shown, but the survey will auto progress through the whole question, displaying the remaining questions for 1 second before progressing to the next. This continues through the remaining of the page, even for questions in other blocks without the code.
Would anyone happen to know what's wrong, or have a preset template for the math task that I can use?
I've attached the Javascript I'm using below:
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/
function startTimer(duration) {
var timer = duration;
var myTimer = setInterval(function() {
Qualtrics.SurveyEngine.setEmbeddedData('TimeLeft', timer);
if (--timer < 0) {
clearInterval(myTimer);
timeOver();
}
}, 1000);
}
var timerSeconds = parseInt("${e://Field/TimeLeft}");
startTimer(timerSeconds);
var timeOver = function() {
$('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*/

});

Be the first to reply!

Leave a Reply