Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic implementation of the participants methods #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions limesurveyrc2api/limesurveyrc2api.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,28 @@ def add_participants(self, session_key, survey_id, participant_data,
response = self.api.utils.request(data)
return response

def get_participant_properties(self, session_key, survey_id, token):
"""
Returns settings of a token/participant of a survey

Parameters
:param session_key: Active LSRC2 session key
:type session_key: String
:param survey_id: ID of survey to get participants from.
:type survey_id: Integer
:param token: token ID for participant to get.
:type token: Integer
"""
params = OrderedDict([
('sSessionKey', session_key),
('iSurveyID', survey_id),
('iTokenIDs', token),
('aTokenProperties', ['tid','completed','participant_id','language','usesleft','firstname','lastname','email','blacklisted','validfrom','sent','validuntil','remindersent','mpid','emailstatus','remindercount ']),
])
data = self.api.utils.prepare_params('get_participant_properties', params)
response = self.api.utils.request(data)
return response

def delete_participants(self, session_key, survey_id, tokens):
"""
Delete participants (by token) from the specified survey.
Expand All @@ -184,6 +206,47 @@ def delete_participants(self, session_key, survey_id, tokens):
response = self.api.utils.request(data)
return response

def invite_participants(self, session_key, survey_id, tokens=False):
"""
Invites participants in a survey
Returns array of results of sending

Parameters
:param session_key: Active LSRC2 session key
:type session_key: String
:param survey_id: ID of survey to invite participants from.
:type survey_id: Integer
:param tokens: List of token IDs for participants to invite.
:type tokens: List[Integer]
"""
params = OrderedDict([
('sSessionKey', session_key),
('iSurveyID', survey_id),
('aTokenIDs', tokens)
])
data = self.api.utils.prepare_params('invite_participants', params)
response = self.api.utils.request(data)
return response

def remind_participants(self, session_key, survey_id):
"""
Send a reminder to participants in a survey
Returns array of results of sending

Parameters
:param session_key: Active LSRC2 session key
:type session_key: String
:param survey_id: ID of survey to invite participants from.
:type survey_id: Integer
"""
params = OrderedDict([
('sSessionKey', session_key),
('iSurveyID', survey_id)
])
data = self.api.utils.prepare_params('remind_participants', params)
response = self.api.utils.request(data)
return response


class _Questions(object):

Expand Down