How to save embedded data from loop question | XM Community
Skip to main content

Hello, I am making a Stroop task, choosing color of text despite the word itself is different color. I used loop&merge feature to randomly choose a word and color. I added embedded data variable called “Feed”. I manage to make a feedback page where participants can see the feedback whether they are correct or wrong. Yet, in the data&analysis page, there is only one Feed variable, meaning I can only see the result of last question whether they got it correct or wrong. How can I add a code to record all feedback data?

I am adding my code here

Qualtrics.SurveyEngine.addOnload(function()
{
$('Buttons').hide();
});
Qualtrics.SurveyEngine.addOnReady(function()
{
var b = parseInt('${q://QID1212377431/SelectedChoicesRecode}');
var B = parseInt('${lm://Field/1}');
if (b == B){
Qualtrics.SurveyEngine.setEmbeddedData('Feed','Correct');
} else {
Qualtrics.SurveyEngine.setEmbeddedData('Feed', 'Wrong');
}
});
Qualtrics.SurveyEngine.addOnUnload(function()
{
$('Buttons').hide();
});

 

Within your loop&merge section you could create a text entry question (hidden with JavaScript) - and then use piping to set the value of that text entry question equal to Feed. 

You should then have the value of Feed stored in each loop in the text entry question.

 


yes, adding to above @MikeW ‘s comment. make sure to create that text entry question after page break if you want to pipe default value and make it hide and autoforward through JS. else punch the value in text box through JS instead of pipe, in that case autoforward is not required you will only need to hide this through JS or normal CSS.

 


Thank you for your reply, to pipe the value of entry to embedded data “Feed”, is it possible to set default option to be “Feed” or do I have to change the Javascript of text entry?


You can set the default value from Default choice option under question text property and can replace it through JS based on your logic requirements. 

 


@hwanee - You might be interested in this Stroop function.


Thank you so much for your reply! I am a complete novice of qualtrics. If it is ok with I have one more question. Instead of adding new question, I change the text question which display the feedback whether the result is correct or wrong into text-entry question and hide the answer box. Then, when the feedback is showing the answer box is also shown like a millisecond and then disappear. Is there a better way to hide the answer box or it is better to create a hidden text entry question after page break. If so, do I have hide with javascript code or display logic? 


Are you currently “hiding” it using a timing question? That can work, but add padding at the top of the question text for that question, so that the answer isn’t visible (as it will now be way off the bottom of the page)…

Or you can use JavaScript. If you search the community for hide a question with JavaScript, I’m sure you’ll find the answer easily.


Thank you


 

You can simply pass one loop field as below to get the iteration number. the find the QID of your question and replace it with QID3 from below code and replace the loop piping text from ${lm://Field/1}. and pass this code under the addOnload().

 

var qid="#"+'${lm://Field/1}'+"_QID3"
jQuery(qid).css("display","none");

 


Leave a Reply