Integrating data from previous respondents into survey | XM Community
Skip to main content

I have a survey with a question asking respondents about their opinion on

x
, measured on a numeric scale. I would like to have a variable
mu_x
that tells me at any given time the average value on all responses of other (previous) respondents on
x
. I would like to include this variable
mu_x
in the same questionnaire at a later point. (So obviously this won't work for the first respondent, for whom there haven't been any previous reponses.)
Is this possible in Qualtrics and how?

One option would be to call a webservice, like GitHub etc., before and after the question.
After the answer you could send it to be written on a page. Before the question, you could request the data on the page. Do the required calculations via JS and then store it in an embedded data which you can display to your participants.


Many thanks, this approach sounds promising!
As I am not knowlegeable about this, could you point me to any good explanation how to do GET and POST requests to Github (or any other service)?


I hadn't come across any one that were good for beginners. The Github api docs (https://docs.github.com/en/free-pro-team@latest/rest) was what I followed. Import the QSF file, it has all the components that I think you need. A few things to note:

  • I'm using a private repo "github.com/tafakkur/blog" So you'll have to make changes accordingly in the web service requests.

  • Data to and from Github is Base64 encoded, so in the JS you'll see atob and btoa functions for that.

  • The compare IDs block is required, as Github appends its data with a "\\n", causes an error is read directly in JS. Therefore, I first pasted the response in a question text and then parsed it.

Check_Unique_ID.qsf
Let me know if it works for you.


Alternatively, you can try this: https://nd.service-now.com/kb_view.do?sysparm_article=KB0018743

It doesn't work for me, but I've seen it work for quite a few people.


Thanks so much, that's already very helpful!
Any chance you could let me know how your github repo looked like? Specifically "https://api.github.com/repos/tafakkur/blog/contents/README.md" from where you GET "content" and "sha"?


It's empty. Just create a repo and github will guide you towards creating a README.md and initializing it. Then change the following in the link:

  • tafakkur
    : Replace with your username

  • blog
    : Replace with repo name

  • README.md
    : You can either keep this, or change it to any other file in the repo.

You'll also need to create a token (https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token) in the survey flow, replace "Your Token Here" with the token you generate.
So in the first webservice request (method = GET). The Authorization header should look something like
token aasdfasd32342sadf

Click on "Test" and Qualtrics will give you the option to "Add Embedded Data". Select
sha 
and
content

Let me know if you need more help.
If you can wait till the 15th, I'm writing a tutorial on this for my school. I'll also post it here: https://github.com/tafakkur/QualtricsHub


Once again, many thanks! It's great that you're doing this, also your repo on Qualtrics.
I got the API connection working. However, the questionnaire does not work yet. If I get it right, it is supposed to check whether the id someone puts in is already in "old_data" on Github. A new id gets then added to "new_data" and pushed to Github. So, if I enter the same id twice, the second time I should get the "fail" message. However, this is not what happens.
Also, I am wondering where in Github the list of ids is actually stored?


I just checked. It is working. There must be some error in your configuration, please recheck it. You've got the flow right.
The list of ids will be in a file in your github repo. So, based on my link:

https://api.github.com/repos/tafakkur/blog/contents/README.md

The list of ids is at
https://github.com/tafakkur/blog/blob/main/README.md

The easiest way to find it is to go to the repo you have created and there you'll see all the files.
Just FYI: These links won't work for you, as they are in the repo
blog
, which I have made private as I'm storing unique ids.


My bad - it just messed up something in Qualtrics. It now works.
Many thanks again, and also looking forward to your tutorial!


Leave a Reply