From 0016f54d3fa05fa57b50b095552aa61c358940fd Mon Sep 17 00:00:00 2001 From: Arnaud Jacquemin Date: Tue, 14 Feb 2017 11:36:15 +0100 Subject: [PATCH] Basic implementation of the following methods : * get_participant_properties * invite_participants * remind_participants --- limesurveyrc2api/limesurveyrc2api.py | 63 ++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/limesurveyrc2api/limesurveyrc2api.py b/limesurveyrc2api/limesurveyrc2api.py index 29dbd89..ce4eb69 100644 --- a/limesurveyrc2api/limesurveyrc2api.py +++ b/limesurveyrc2api/limesurveyrc2api.py @@ -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. @@ -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):