ropensci / qualtRics

Download ⬇️ Qualtrics survey data directly into R!
https://docs.ropensci.org/qualtRics
Other
215 stars 70 forks source link

Text topics not included when survey imported #121

Closed CaseyTAA closed 4 years ago

CaseyTAA commented 5 years ago

I assigned text responses to certain topics using the text tab in qualtrics. This field shows up under embedded data on the qualtrics site, but does not get imported into R after fetch_survey call. Is there a way to get this field to be included?

juliasilge commented 5 years ago

Thanks for reporting this @CaseyTAA! We also are not currently importing the sentiment scores that can be assigned; this also needs to be added.

juliasilge commented 5 years ago

Turns out I don't have these options available on the account I use, so I am going to need somebody to contribute who has experience with this. I'm officially looking for help!

@CaseyTAA would you be interested in contributing?

CaseyTAA commented 5 years ago

I'm not sure how capable I am, but I would love to help if I can

danfredman commented 5 years ago

@juliasilge I'm trying to do the same thing as @CaseyTAA. Looking at the API docs got me here but I can't see if there's a way to specifically as for the text iQ fields. I'd be happy to help too, if I can.

juliasilge commented 5 years ago

Thank you both so much for being willing to help in situations! 🙌

A starting place will be to look at the survey metadata and see if there is any information about the text iQ fields in there. You can get that in this way:

# make URL for request
root_url <- qualtRics:::append_root_url(Sys.getenv("QUALTRICS_BASE_URL"), "surveys")

root_url <- paste0(
  root_url,
  "/",
  my_id   ## put an ID here for a survey that has text topics assigned
)

# GET request to download metadata
resp <- qualtRics:::qualtrics_api_request("GET", root_url)

The resp object will be an unwieldy list, but you can look through it and see what you find. For example, resp$result$exportColumnMap contains the column mapping.

If you want to see what you can find in the survey itself, try out the responseexports endpoint.

# make URL for request
root_url <- qualtRics:::append_root_url(Sys.getenv("QUALTRICS_BASE_URL"), "responseexports")

# what are we requesting?
raw_payload <- qualtRics:::create_raw_payload(
  surveyID = my_id,        ## put an ID here for a survey has text topics assigned
  label = TRUE,
  last_response = NULL,
  start_date = NULL,
  end_date = NULL,
  limit = NULL,
  local_time = FALSE,
  unanswer_recode = NULL,
  include_questions = NULL
)

resp <- qualtRics:::qualtrics_api_request("POST", url = root_url, body = raw_payload)
ID <- resp$result$id
check_url <- paste0(root_url, ID)
survey.fpath <- qualtRics:::download_qualtrics_export(check_url, verbose = TRUE)
readr::read_csv(survey.fpath)

From how I read this page, it sounds like using this endpoint should return the text iQ fields. Do you see any in the results?

CaseyTAA commented 4 years ago

I ran the code with the suggested endpoint, but I get all the same columns that I did using fetch_survey(), no topics. "resp$result" has a field named comments, which seems promising, but unfortunately it is just an empty list.

image

juliasilge commented 4 years ago

Hmmmmm, OK, that is a bummer. Thank you so much for checking on these initial ideas. I am going to do some more digging into the API documentation.

If you export the survey from the web UI (for example, as a CSV) do you see the text iQ fields?

Screen Shot 2019-09-28 at 9 40 18 PM

CaseyTAA commented 4 years ago

Yes, the topics are included if you export the survey from the qualtrics UI

juliasilge commented 4 years ago

The topics and sentiment scores are now imported, after moving to the new API endpoint in #135.