I want the respondents to answer a question for 120 seconds, and then show the respondents scores later, based on how many question they have created.
What I did is that I used custom JS code to automatically hit next button after 120 seconds, and then get the inputs in the textbox into embedded data.
Here's the custom code that I used:
Qualtrics.SurveyEngine.addOnReady(function()
{
setTimeout(function () {jQuery('#NextButton').click();},120000);
$('NextButton').onclick = function (event) {
Qualtrics.SurveyEngine.setEmbeddedData( "answer1", document.getElementById("QR~QID47").value);
}
});
However, the timing was not as accurate as I hoped for, so I added the auto advance timer feature provided by Qualtrics.
Now, the problem is that the custom code auto advance and qualtrics auto advance may be colliding, that the page flips over earlier or later than the set time, 120 seconds.
I think I should lose the setTimeout and replace it with something else, so that it would still get the input text after 120 seconds with qualtrics auto-advance controlling the timing.
How can I replace setTimeout and still get the text input that the repondents wrote for 120 seconds? Or are there any other ways to work around this auto-advance collision problem?
Any advice will be appreciated, please help
Just remove JS line that clicks next button i.e. remove setTimeout line.
Thanks for the comment Shashi!
However, that doesn't solve the problem.
Next button is hidden on our page and if I delete the setTimeout line there is no event to trigger getElementById.
Is there any other way around this?
Hi Kibbeum,
I think you may be overthinking this. I can't test this right now, but could you not just set the answer1 embedded field to pipe in from the question?
eg similar to this screenshot from the documentation:
This way answer1 will always populate based on the user's selection, and you can just use the built in Qualtrics timer.
PS - timers in a browser tend to have a few factors which can cause delays.
Good luck!
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.