Solved
How to save an array of reaction times in Embedded Data?
I made a survey with a loop/merge element. Each loop contains a single MC question. I want to get the reaction time for each question and append that to the end of an Embedded Data variable so that the end product is an array containing the reaction time for each question.
So far, the code I have is:
Qualtrics.SurveyEngine.addOnReady(function()
{
var starttime = new Date().getTime();
$('NextButton').hide();
this.questionclick = function(event,element){
if (element.type == 'radio') {
var endtime = new Date().getTime();
var RT = endtime - starttime;
var EmData = Qualtrics.SurveyEngine.getEmbeddedData('reactiontime');
let Holder = [];
Holder.push(EmData);
Holder.push(RT);
Qualtrics.SurveyEngine.setEmbeddedData('reactiontime', Holder);
$('NextButton').click();
}
}
});
This code results in something like the following:
[[{"1":4697},2943],"10392"]
where the larger numbers are the RTs. No idea where the "1" comes from. So, it works, but is a mess. I was wondering if there was a way to alter my code so that the Embedded Data ends up looking like this by the end of the survey:
[RT1, RT2, RT3...]
rather than the messy current form.
Thanks in advance for your help!
(sorry if the formatting is poor, I am new to this forum)
Best answer by TomG
The problem is you are saving an array to the embedded data field when what you want is a string. Instead you could do something like:
```
var EmData = Qualtrics.SurveyEngine.getEmbeddedData('reactiontime');
if(EmData.length > 0) EmData += ", ";
EmData += RT;
Qualtrics.SurveyEngine.setEmbeddedData('reactiontime', EmData);
```
View originalLeave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.