question about copying randomly displayed text from one block to another | XM Community
Skip to main content

Hi all,
I asked qualtrics support, but they do not seem to have a good solution to this, so I hope someone here can help me.
I have a survey in which those who take the survey (participants) see one random text out of a total of 120 that they can possibly see. These texts appear in different block. Specifically, I have 6 blocks (so that different participants are randomly assigned to different blocks) and within each block I have 20 different potential texts, out of which they see one. I am using embedded data with text = 1 to 20, and different names for the different blocks/groups.
In a later stage, I want to remind participants the specific text they saw. The current solutions I have is to set 120 "display if" statements in the block itself or 120 embedded data statements (where I set an embedded data for "text_displayed" for each text they see) in the Survey flow and then displaying the "text_displayed" question in the block.
I was wondering if there is an easier "catch all" solution, such as adding a piece of code to display the correct text again?
Thanks in advance,
Margarita  



How are you setting a the embedded data field 'text' a value of 1 to 20? Could you set an embedded data field containing the actual text (e.g., pipeText) at the same time? If so, then you can pipe the embedded data where ever you need to display it.
It that doesn't work, you could add JS to your existing questions where you display text the first time and save the text to an embedded data field. It would be something like:
Qualtrics.SurveyEngine.addOnload(function() {
var pipeText = jQuery("#"+this.questionId+" .QuestionText").html();
Qualtrics.SurveyEngine.setEmbeddedData("pipeText",pipeText);
});
Later in the survey, pipe

${e://Field/pipeText}
when you want to display the text.


At the beginning of the Survey flow I set embedded data of "text number"= 1 to 20.
Then in each block I have all the text appearing in the block as separated texts and "display if" statements (e.g., if "text number = 1" it displays the first text in the block, if text number = 2 it displays the second etc.).
Because in each block there are only 20, it is still manageable to follow all the statements (i just do this for each of the 6 blocks). However, I am concerned it will not be manageable for all 120 texts in one block.
Could you explain a bit more your suggestion? I do not have programming background, so i am struggling to understand this a bit.


https://community.qualtrics.com/XMcommunity/discussion/comment/51249#Comment_51249Copy and paste the JavaScript I provided above into each of the 20 text questions in the 6 blocks (120 total). It will save the one text the respondent sees into an embedded data field named pipedText. Later in the survey, you just need one question where you pipe that value

${e://Field/pipeText}
. It will display the text the respondent saw earlier.
If you want pipeText saved in your response data, add it as an embedded data field at the beginning of the survey flow with no value assigned.


Thanks! I'll try it out.
When I open the javeScript of each text I see the following:
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*/
});
Qualtrics.SurveyEngine.addOnUnload(function()
{
/*Place your JavaScript here to run when the page is unloaded*/
});

Do I put your code after all of this or instead it somewhere in a specific location?


Just replace the whole thing. On Windows, Ctrl+a (select all), Ctrl-v (paste).


https://community.qualtrics.com/XMcommunity/discussion/comment/51253#Comment_51253Thank you very much. This was super helpful! :)


Leave a Reply