- Posts: 103
- Thank you received: 5
Ask the community, share ideas, and connect with other LimeSurvey users!
resp <- call_limer(method = "list_participants", params = list(iSurveyID = sid))
tok <- call_limer(method = "get_participants_properties", params = list(iSurveyID = sid)) str(tok)
tok <- call_limer(method = "list_participants", params = list(iSurveyID = sid)) str(tok)
tok <- call_limer(method = "get_participant_properties", params = list(iSurveyID = sid)) str(tok)
### List participants with method list_participants via limer tok <- call_limer(method = "list_participants", params = list(iSurveyID = sid)) str(tok)
'data.frame': 10 obs. of 3 variables: $ tid : chr "1" "2" "3" "4" ... $ token : chr "token1" "token2" "token3"... $ participant_info:'data.frame': 10 obs. of 3 variables: ..$ firstname: chr "" "" "" "" ... ..$ lastname : chr "" "" "" "" ... ..$ email : chr "email1@email.com" "email2@email.com" "email3@email.com ...
### Function get_participants() from limer #https://github.com/cloudyr/limer/blob/7c10cc62f703d03bcac23fb444ebd39cf5d0e2b0/R/get_participants.R attr <- c('email', 'usesleft') # select some attributes. tok <- get_participants(sid, iStart=0, iLimit=10, bUnused=FALSE, aAttributes=attr) str(tok)
'data.frame': 10 obs. of 4 variables: $ tid : chr "1" "2" "3" "4" ... $ token : chr "token1" "token2" "token3" ... $ participant_info:'data.frame': 10 obs. of 3 variables: ..$ firstname: chr "" "" "" "" ... ..$ lastname : chr "" "" "" "" ... ..$ email : chr "mail1@mail.com" "mail2@mail.com" "mail3@mail.com" ... $ usesleft : chr "1" "1" "1" "1" ...
tok$usesleft # vector of usesleft
[1] "1" "1" "1" "1" "1" "1" "1" "1" "1" "1"
### Method get_participant_properties (via limer) # https://api.limesurvey.org/classes/remotecontrol_handle.html#method_get_participant_properties attr <- c("tid", "email", "token", 'usesleft', 'attribute_1') tok <- call_limer(method = "get_participant_properties", params = list(iSurveyID = sid, tokenid = 1, aTokenProperties = attr)) str(tok)
List of 4 $ tid : chr "1" $ email : chr "email1@email.com" $ token : chr "token1" $ usesleft: chr “1”
# https://api.limesurvey.org/classes/remotecontrol_handle.html#method_set_participant_properties call_limer(method = "set_participant_properties", params = list(iSurveyID = sid, tokenid = 1, aTokenProperties = "usesleft", aTokenData = ?????))
$aTokenQueryProperties array|integer of participant properties used to query the participant, or the token id as an integer
$aTokenData array Data to change
$aTokenQueryProperties = [useLeft=>1] $aTokenData = [useLeft=>2]
call_limer(method = "set_participant_properties", params = list(iSurveyID = sid, tokenid = 1, aTokenData = list(usesleft = "2"))) }
# Which tokens to change? id.select <- 1:100 # A Loop to apply these changes sequentially for(i in id.select){ call_limer(method = "set_participant_properties", params = list(iSurveyID = sid, tokenid = i, aTokenData = list(usesleft = "2"))) }
call_limer(method = "set_participant_properties", params = list(iSurveyID = sid, aTokenQueryProperties = list(usesleft = "1"), aTokenData = list(usesleft = "2")))
aTokenQueryProperties = list(usesleft = "1")
aTokenQueryProperties = list(usesleft = "2")
call_limer(method = "set_participant_properties", params = list(iSurveyID = sid, aTokenQueryProperties = list(usesleft == "1"), aTokenData = list(usesleft = "2")))
# Changes participant with tid = 1 to usesleft = 2: call_limer(method = "set_participant_properties", params = list(iSurveyID = sid, aTokenQueryProperties = list(usesleft = "1"), aTokenData = list(usesleft = "2"))) # Same as above, despite naming the aTokeQueryProperties "foo": call_limer(method = "set_participant_properties", params = list(iSurveyID = sid, aTokenQueryProperties = list(foo = "1"), aTokenData = list(usesleft = "2"))) # Changes participant with tid = 3 to usesleft = 2: call_limer(method = "set_participant_properties", params = list(iSurveyID = sid, aTokenQueryProperties = list(usesleft = "1"), aTokenData = list(usesleft = "2"))) # Despite tid = "4" changes participant with tid = 1 to usesleft = 2: call_limer(method = "set_participant_properties", params = list(iSurveyID = sid, aTokenQueryProperties = list(tid = "4", usesleft = "1"), aTokenData = list(usesleft = "2"))) # I tried to set all participants with language the same language (here "de" for German) to usesleft = 2, but this returns # $status # [1] "Error: Invalid tokenid" call_limer(method = "set_participant_properties", params = list(iSurveyID = sid, aTokenQueryProperties = list(language = "de"), aTokenData = list(usesleft = "2"))) # Returns: # $status # [1] "Error: Invalid tokenid" call_limer(method = "set_participant_properties", params = list(iSurveyID = sid, aTokenQueryProperties = list("usesleft = 1"), aTokenData = list(usesleft = "2"))) # Returns same as above: call_limer(method = "set_participant_properties", params = list(iSurveyID = sid, aTokenQueryProperties = list("usesleft = '1'"), aTokenData = list(usesleft = "2")))