Skip to content

Commit 2a9ee75

Browse files
author
Suchard
committed
Finish readme
1 parent 870c197 commit 2a9ee75

2 files changed

Lines changed: 30 additions & 17 deletions

File tree

README.md

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,40 @@
1-
Setup
2-
* Create a virtual environment with pip install -r requirements.txt
1+
## Instructions
2+
The functions in this repository are wrappers for survey management tasks that require multiple Qualtics API calls.
33

4+
### Setup
5+
Before you can use the functions, you need to:
6+
7+
* Create a virtual environment, and pip install the requirements.txt
8+
9+
* Input your Qualtrics API token in qualtrics_settings.py. You can get it by going to Qualtics --> click on your username --> Account settings
10+
11+
* Add a survey ID in qualtrics_settings.py. It can be found in the URL of your survey, starting with the letters SV. You can add multiple survey IDs to qualtrics_settings.py, and you can name them whatever you want. This step isn't required, but makes it easy to refer to different surveys when running the functions.
12+
13+
* Manually add some contacts to the survey. The functions assume that the contacts are set up in a cetain way, where the ExternalDataReference = another field, which has been turned into an embedded field. It's only possible to set it up manually the first time. If they survey is new, add some respondents from a CSV first before using the functions.
14+
15+
### Adding someone to a survey
16+
17+
**Step 1: Find DistributionID**
18+
19+
Your survey may contain multiple Personal Links distributions. A distributions is the channel by which a survey is sent out to respondents. You must find the DistributionID of the one that you want to add a person to. You can use the function get _distributions(). In the first parameter, fill in the SurveyID of your Survey.
20+
21+
The DistributionID always starts with EMD_. In the example, the survey has two distributions. Run the function to get the DistributionID and date created of each one, so you can easily choose the one you want. In this case, you want test_contact_list.
422

5-
Adding an individual to a survey
6-
1. Find DistributionID
7-
Your survey may contain multiple Personal Links distributions. A distributions is the channel by which a survey is sent out to respondents. You must find the DistributionID of the one that you want to add a person to. You can use the function get _distributions(). In the parameter, fill in the SurveyID of your Survey.
8-
The DistributionID always starts with EMD_. In my example, my survey has two distributions. I run the function to get the DistributionID and date created of each one, so I can easily choose the one I want. In this case, I want test_contact_list.
923
<img width="602" height="326" alt="image" src="https://github.com/user-attachments/assets/c94e87cd-0e83-4479-951f-4e8b7dd581b9" />
1024
<img width="555" height="59" alt="image" src="https://github.com/user-attachments/assets/651de9d5-65fd-49cb-aced-37312548a45d" />
1125

26+
**Step 2: Add an individual to a Survey**
1227

13-
2. Add an individual to a Survey
1428
You add a new individual to a survey by adding them to a distribution. A distribution is always linked to exactly one mailing list. Therefore, you must add this individual to the mailing list.
15-
Use the function add_individual_to_survey(). The first argument is the person’s Study ID, which is internal to the study at hand. The second argument is the ID of the survey. The third is the distribution_id found in step 1.
16-
The function adds this individual’s Study ID to the right mailing list, which in turn adds it to the distribution. If the Study Id already exists in this mailing list, it won’t be added again and you’ll get a warning.
17-
The individual’s Personal Link to the survey is printed.
18-
Getting an individual’s progress on a survey
19-
Use the get_individual_progress() function. The first argument is the individual’s Study ID. The second is the field being used as the Emebedded Data Field. The third is the ID of the survey.
20-
Remember that it can take Qualtics ~5 minutes
21-
The function works by requesting an export from Qualtrics, waiting for it, downloading it, and then filtering for the person. If we wanted to get multiple individuals’ progress at once, the function could be modified to filter for multiple study IDs.
2229

30+
Use the function add_individual_to_survey(). The first argument is the person’s Study ID, which is internal to the given study. The second argument is the Qualtrics ID of the survey. The third is the distribution_id found in step 1.
2331

32+
The function adds this individual’s Study ID to the right mailing list, which in turn adds it to the distribution. If the Study Id already exists in this mailing list, it won’t be added again and you’ll get a warning.
2433

34+
The individual’s Personal Link to the survey is printed.
2535

36+
### Getting someone's progress on a survey ###
2637

38+
Use the get_individual_progress() function. The first argument is the individual’s Study ID. The second is the field being used as the Emebedded Data Field (for example, "study_id_child"). The third is the ID of the survey.
2739

40+
The function works by requesting an export from Qualtrics, waiting for it, downloading it, and then filtering for the person's ID. If we wanted to get multiple individuals’ progress at once, the function could be modified to filter for multiple study IDs.

qualtrics_settings.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
BASE_URL = "https://fra1.qualtrics.com/API/v3"
99
HEADERS = {
1010
"Content-Type": "application/json",
11-
"X-API-TOKEN": "u2ufrDKnw5plXTrzkTnoV0rGtxC0hZJ2rjVAguDD"
11+
"X-API-TOKEN": "# API TOKEN HERE #"
1212
}
1313

1414
class QualtricsAPIError(Exception):
1515
pass
1616

1717
class SURVEYIDS():
18-
my_test_survey_id = "SV_0llWVSZNOQOorSC"
19-
my_test_survey2_id = "SV_efCMOg6wHU0T8ii"
18+
my_test_survey_id = "# A survey ID goes here: SV_XXXXXXXXXXXXX1 #"
19+
my_test_survey2_id = "# A survey ID goes here: SV_XXXXXXXXXXXXX2 #"

0 commit comments

Comments
 (0)