Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

create survey participants via remote interface

  • michaelsvenna
  • michaelsvenna's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 9 months ago #200703 by michaelsvenna
Hi, I am quite new to lime survey.
I have a system setup with a survey and there are already participants in there.

I need to be able to create new participants by providing a token and a username (at least a token).

I have noticed in the docs that there is a remote interface available.

To create these participants using the remote interface - should I use `activate_tokens` or `add_participants`? I have to add A LOT of users, so if there are possibilites of doing bulk creation that would be super helpful.

Please help me get started with this.

Thanks :)
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 9 months ago #200711 by Joffm
Hi,
so you want to add new participants of a survey?
You see, there is no "username", only "firstname" and "lastname".

And the quick and easy thing is to upload your participants as csv-file.
manual.limesurvey.org/Survey_participant...ants_from_a_CSV_file

Or do you want to create new users (admins) of LimeSurvey?

Obviously I am confused by your word "participants".

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 9 months ago - 3 years 9 months ago #200716 by tpartner

To create these participants using the remote interface - should I use `activate_tokens` or `add_participants`?

Here is a simple example of how to add a participant using the API - forums.limesurvey.org/forum/development/...-custom-token#193943

- manual.limesurvey.org/RemoteControl_2_API

- api.limesurvey.org/classes/remotecontrol...hod_add_participants

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 3 years 9 months ago by tpartner.
The topic has been locked.
  • michaelsvenna
  • michaelsvenna's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 9 months ago #200717 by michaelsvenna
Replied by michaelsvenna on topic create survey participants via remote interface
Hi, thanks for the replies. I managed to make it working.
If anyone is interested, here is how i did the implementation in python (django):

survey_data = [{'token':str(u.pk)} for u in us]
r = requests.post(
f'{survey_base}/index.php/admin/remotecontrol',
json = {
"method":"get_session_key",
"params":[survey_uname,survey_pwd],
"id":1
}
)

session_key = json.loads(r.content)
r = requests.post(
f'{survey_base}/index.php/admin/remotecontrol',
json = {
"method":"add_participants",
"params":[
session_key,
survey_id,
survey_data,
False # do not create token, instead use supplied token
],
"id":1
}
)

r = requests.post(
f'{survey_base}/index.php/admin/remotecontrol',
json = {
"method":"release_session_key",
"params":[session_key],
"id":1
}
)
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose