Using the Qualtrics API, you can peform a number of manipulations of survey objects in your Qualtrics account.
You can easily retrieve the full list of surveys available in your account:
surveys <- list_surveys() head(surveys) #> # A tibble: 6 × 6 #> id name ownerId lastModified creationDate isActive #> <chr> <chr> <chr> <chr> <chr> <lgl> #> 1 SV_39rgGREdlmzH63X api_copy_… UR_1Z96ys… 2020-06-11T08… 2020-06-10T0… TRUE #> 2 SV_3fmfHkdddhnRbKJ api_copy_… UR_1Z96ys… 2020-06-11T08… 2020-06-11T0… FALSE #> 3 SV_6WpcSqtVBsibNcN api_copy_… UR_1Z96ys… 2020-06-11T08… 2020-06-11T0… FALSE #> 4 SV_9Ak7vCha9W42Twp api_copy_… UR_1Z96ys… 2020-06-11T08… 2020-06-11T0… FALSE #> 5 SV_aYwagyEbamVLpFX api_copy_… UR_1Z96ys… 2020-06-11T08… 2020-06-11T0… FALSE #> 6 SV_blW4HuzdeqLiTJ3 api_expor… UR_1Z96ys… 2020-04-16T18… 2020-04-16T1… TRUE
Using a survey id, you can retrieve the survey object from your account:
srv_obj <- get_survey(surveys$id[1])
The call returns a list that provides a number of information related to the status of the survey, providing a quick and efficient way to see the number of survey responses for example, instead of going through the more time consuming process of exporting all survey responses through get_survey_responses()
.
names(srv_obj) #> [1] "QuestionCount" "SurveyOptions" "SurveyID" "SurveyName" #> [5] "SurveyStatus" "LastModified" "BrandID" "OwnerID" #> [9] "LastAccessed" "CreatorID" "LastActivated" "Questions" #> [13] "Blocks" "ResponseSets" "SurveyFlow" "Scoring" #> [17] "ProjectInfo" "BrandBaseURL"
A small number of survey options can be easily updated through the below. These include: the survey name, the activity status, the time range and the owner id.
# set status to active update_survey(surveys$id[1], status = TRUE) # set time range update_survey(surveys$id[1], expiration = c("2016-01-01T01:00:00Z","2016-03-01T01:00:00Z"))
An exhaustive list of survey options are configurable through the update_options()
call.
update_options(surveys$id[1], list("BackButton" = true, "BallotBoxStuffingPrevention" = true))
All available options can be found in the documention.
You can create a copy of a survey in your own account or in another user’s account using the user id (if you are a brand administrator, see list_users()
):
# Copy a survey in your own account copy_survey(survey_id, "New_Copy") # Copy a survey to another user's account copy_survey(survey_id, "New_Copy", user_id)
The survey id of the new copy will be returned.
You might not want to copy a survey into another person’s account but would rather share the project defining a specific set of permissions. By default, without any specification, your project will be shared with all permissions disabled. You can decide which permissions to enable by providing an array of numbers indicating the permissions you want to enable.
The available options are listed below:
"1"="copySurveyQuestions" "2"="editSurveyFlow" "3"="useBlocks" "4"="useSkipLogic" "5"="useConjoint" "6"="useTriggers" "7"="useQuotas" "8"="setSurveyOptions" "9"="editQuestions" "10"="deleteSurveyQuestions" "11"="editSurveys" "12"="activateSurveys" "13"="deactivateSurveys" "14"="copySurveys" "15"="distributeSurveys" "16"="deleteSurveys" "17"="translateSurveys" "18"="editSurveyResponses" "19"="createResponseSets" "20"="viewResponseId" "21"="useCrossTabs" "22"="downloadSurveyResults" "23"="viewSurveyResults" "24"="filterSurveyResults" "25"="viewPersonalData"
As an example, to share the survey with only distribution rights enabled, you run the following call:
share_survey(my_surveys[1], user_id, 15)
Previous calls are overridden by any new permissions setting so you must set every permission each time. To add permissions to visualize the data, do:
# enable permissions for distribution and data visualisation share_survey(my_surveys[1], user_id, c(15,23)) # remove permission to visualize the data share_survey(my_surveys[1], user_id, c(15))
You can import a local survey file into Qualtrics. The accepted file formats are qsf, txt and doc (word document). The qsf format stands for qualtrics survey file and is usually a file exported from Qualtrics. This is however nothing else than json that is not impossible to build from scratch (be ready to sweat though).
The file can be imported from a local path or directly from a url:
# Import a local qsf file into Qualtrics import_survey("name", "./survey.qsf", 1) # Import a file from a url import_survey("name", "https://www.example.com/mysurvey.qsf", 1)
You can check the languages currently enabled for the survey with get_survey_languages
. You can update available languages, for example adding Spanish and Portuguese to the base english survey:
update_survey_languages("SV_1873930DS2", c("EN", "ES", "PT"))
You can retrieve a given translation, which will return a list of all survey textual items that can be translated.
srv_transl_pt <- get_survey_translations("SV_1873930DS2", "PT")
This can be useful if you want to handle your translation process outide of Qualtrics. Provide you keep the item references and struture of the list untouched, you will thn be able to update the survey translation back into Qualtrics:
update_survey_translations(id, "PT", srv_transl_pt)
Another compelling use case is to export different languages from multiple clones of a survey and import it back into the master version.