How can I ask a survey question that contains information from a previous response | XM Community
Skip to main content

Hello,
I would like to do the following in a qualtrics survey:

  1. Have respondents copy and paste a large list into a text entry box

  2. Loop through each line of their entry and execute some edits.

  3. Ask a multiple choice question in which the options are a random subset of the edited lines from (2).

Does anyone have a clear way to perform a task like this?. I am mostly having issues with step (3), but any help would be appreciated
Another option is to replace (1) with "upload a text file", but I am unable to find an easy way to use the data from the text file within the Qualtrics HTML and javascript editors.

faizessa
Not sure how you are doing step2.
If you know the max number of entries a person can enter there might be a better approach but I have one solution which is cumbersome
1. Text entry question which will include all the items comma separated.create number of embedded data in survey flow the max number you feel.
2. Include a JS with split function you can follow this Stack Overflow page to get the values and use Qualtrics set embedded data in JS for each value.
3. Once you have it all in the embedded data you can use randomizer to randomly present data. Out of all the items.

Your other approach of uploading file that would be more difficult as you will have to perform many operations of automating the list for editing it and pulling it back with Qualtrics api.
Hope it helps!



faizessa ,
Is step 2 a loop & merge? If so, is the loop & merge based off a question?


Hi Deepak and TomG,

Thanks for your comments! I'm working with faizessa on this project and can answer some questions:
The entered text will be a mixed list of names and handles, plus some garbage lines. Some of the garbage lines have substrings indicating the next line will be a name. So like this:

  • Garbage line, including a substring indicating the next line is a name

  • Name 1

  • Handle 1

  • Garbage line

  • Garbage line, including a substring indicating the next line is a name

  • Name 2

  • Handle 2

So we'll need to parse this into a list based on linebreaks, not comma-delimited if possible. Then we need to delete entries that are 'garbage' lines, which we can determine because they contain a certain substring in a fixed position in the line.
The data we would like to store is two dimensional, i.e. a handle and name for each entry. Hypothetically I guess this could be a pair of embedded data variables, where the handle and name for the same person could have the same index.
However, the list could be quite long -- perhaps up to 1000 entries or more. So defining 1000x2 embedded variables by hand would definitely be something I would like to avoid. Also, some survey takers will have much fewer than 1000 entries. Alternatively, it would also be fine to store one list of strings for each user as the Name -- Handle.
For presenting questions, I would want to randomly select a subset of the above entries which are non-empty and display the correct handle and name for those individuals.
Thanks for your help in advance and let me know if you have any additional questions!


sbenzell ,
Thanks for the explanation. That's a complex undertaking. What are you hoping to get from the Community?


Hi Tom,
Yep, it's a lot. I guess my first three questions are:
1) Is collecting and parsing this list feasible in Qualtrics, or am I better served creating a standalone website for people to be directed to upload and parse the list, which would then be somehow brought back into Qualtrics?
2) Is there a way to set up 1000s of embedded variables at once for our purposes?
3) If such a thing is possible but complex on Qulatrics, can you recommend a service I could hire to implement this procedure?
Best,
Seth


sbenzell ,

1) Is collecting and parsing this list feasible in Qualtrics, or am I better served creating a standalone website for people to be directed to upload and parse the list, which would then be somehow brought back into Qualtrics?

It is feasible in Qualtrics. The iffy part is relying on people to provide text that adheres to the rules so it can be parsed.
2) Is there a way to set up 1000s of embedded variables at once for our purposes?

Yes, you can do it with a web service. However, its not clear to me that you need 1000s of embedded variables. Do you need to save all the Name/Handle pairs in Qualtrics or only the randomly selected subset of Name/Handler pairs that you will ask questions about? Either way, it is doable, but the data would be cleaner and smaller if the unselected Name/Handler pairs are discarded (they would still be in the original string that would be saved).


sbenzell

Is collecting and parsing this list feasible in Qualtrics, or am I better served creating a standalone website for people to be directed to upload and parse the list, which would then be somehow brought back into Qualtrics?

It is possible but managing/reporting/analyzing would be way too tricky. Also, do check the number of characters allowed in text entry. As far as I know, 20000 is the character limit for single-line text entry.
Is there a way to set up 1000s of embedded variables at once for our purposes?

There is one way, you can create an excel of all the variables, upload it as a contact, use the Add from contacts option, and choose all embedded data that will be added.
If such a thing is possible but complex on Qulatrics, can you recommend a service I could hire to implement this procedure?

Maybe a Qualtrics Implementation Partner can help you here, you can connect with your Account Executive and he will be able to show you the correct direction.

Hope it helps!


https://community.qualtrics.com/XMcommunity/discussion/comment/51400#Comment_51400Hi Tom and Deepak,
thanks for your help with this.
We do need to save all of the names and handles. This is necessary for our analysis. Additionally, the surveys will be conducted in a proctored lab on a college campus, so confusing tasks aren't a problem.
The way I was attempting to do this before was with pyscript (https://pyscript.net/) (I have limited javascript experience, but I can try to do something similar in javascript as well). The plan was to have people paste their lists into an essay box and run a python function on the embedded data that cleans the list. The issue is that I can't run my python function on the embedded data because the list is longer than one line ( "SyntaxError: unterminated string literal (detected at line 26)"). I also can't save the data from my python script into qualtrics.
Is there a way I can save all of the lines in their list as separate embedded variables and parse through them with javascript? I only see a way of using their entire response as an embedded variable.
Faiz


I wouldn't use pyscript - the website says they don't recommend it for production.
You could use JavaScript. Since you want to save all the data in Qualtrics, you'll have to create a lot of embedded data fields in the survey flow. It it were me, I would use a web service to create the fields.
Another alternative is to off-load the entire process to a web service. Post the text to the web service and have it do all the parsing, creation of embedded data fields and random selection for follow-up questions. If you have a server that supports it, you could write the web service in Python.


Leave a Reply