- Posts: 7
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
create survey participants via remote interface
- michaelsvenna
- Topic Author
- Offline
- New Member
Less
More
3 years 9 months ago #200703
by michaelsvenna
create survey participants via remote interface was created 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
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12779
- Thank you received: 3940
3 years 9 months ago #200711
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic create survey participants via remote interface
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
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
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10630
- Thank you received: 3696
3 years 9 months ago - 3 years 9 months ago #200716
by tpartner
- 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.
Replied by tpartner on topic create survey participants via remote interface
Here is a simple example of how to add a participant using the API - forums.limesurvey.org/forum/development/...-custom-token#193943To create these participants using the remote interface - should I use `activate_tokens` or `add_participants`?
- 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
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 0
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
}
)
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.