cloudyr / MTurkR

R Client for the MTurk Requester API
https://cloud.r-project.org/package=MTurkR
91 stars 18 forks source link

HITGroupId to be included in GetHIT() return #126

Closed amatsuo closed 6 years ago

amatsuo commented 6 years ago

It would be great if "HITGroupId" is included the output of GetHIT() in future.

This information is useful to provide a direct link to a HIT as the url of a particular HIT is given in the form of https://worker.mturk.com/mturk/preview?groupId=XXX

I've been preparing a 2-wave survey study where some of participants in Wave 1 will be re-invited to Wave 2 and I wanted to give a direct link in the invitation emails. I cannot check the url in my web browser because I am not qualified to the HIT as a worker and not allowed to preview this hidden HIT.

(This is more of a wishlist. For my current project, I have figured out how to find the information by parsing the output from request()).

leeper commented 6 years ago

I believe it is not possible to get the HITGroupID from the API at all, which is a continuing point of frustration with MTurk.

taneemtee commented 6 years ago

Hey Thomas, I wanted to understand this a little better. Today it is possible to get the "HITGroupId" when calling CreateHIT or GetHIT. In both cases, this value is returned by the API. Are you talking about it being missing in some other context?

leeper commented 6 years ago

Are we talking the legacy API that MTurkR uses it the "new" one?

amatsuo commented 6 years ago

Following codes (which I use for my work) return a HITGroupId and I use in direct messages. So the info exists from GetHIT().

library(MTurkR)
library(dplyr)
library(xml2)
HITId <- "***"
request_result <- request("GetHIT",
                          GETparameters = paste0("&HITId=", HITId), sandbox = FALSE)
hit_group_id  <-
  request_result$xml %>% read_xml %>%
  xml_find_all(xpath = "//HITGroupId") %>% xml_text
leeper commented 6 years ago

Huh, okay. That must have changed. We just need to add a line here for HITGroup, then: https://github.com/cloudyr/MTurkR/blob/master/R/asdataframe.R#L20-L40 and modify this line: https://github.com/cloudyr/MTurkR/blob/master/R/asdataframe.R#L20-L40 so it's always returned as a column name.