I am trying to write code that starts with the slider question, and continuously records the value on the slider every second. To be more specific, my participants will be continuously rating their impressions of a character using the slider while listening to a story. I'm hoping to record their slider value every second and save this as comma separated values in an array.
I'm struggling to properly set up the embedded data saving and the setInterval, and I can't find examples of this anywhere else! Here is what I'm working with so far...
Please note: I am new to this so, if possible, please be specific about where in the code to implement any suggested code chunks or changes. Sincere thank you in advance.
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/
});
Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
var responses = [];
response_interval = setInterval(function(){
var response = parseInt(jQuery("#CRM1 input.ResultsInput").eq(0).val());
response += ", ";
responses.push(response);
}, 1000)
});
Qualtrics.SurveyEngine.addOnUnload(function()
{
/*Place your JavaScript here to run when the page is unloaded*/
clearInterval(response_interval);
});
Qualtrics.SurveyEngine.addOnPageSubmit(function(type)
{
if(type == "next"){
Qualtrics.SurveyEngine.setEmbeddedData("CRM-responses", responses);
}
});
Be the first to reply!
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.