- Posts: 1
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Deactivate Survey with API
- ccarmona
- Topic Author
- Offline
- New Member
Less
More
7 years 3 months ago - 7 years 3 months ago #144983
by ccarmona
Deactivate Survey with API was created by ccarmona
Hi people! If possible to deactivate a survey by API?
We have a activate_survey() function but not deactivate_survey(), only a delete_survey()........
Thanks!
We have a activate_survey() function but not deactivate_survey(), only a delete_survey()........
Thanks!
Last edit: 7 years 3 months ago by ccarmona.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3691
7 years 3 months ago #144991
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Deactivate Survey with API
Not as far as I can see -
api.limesurvey.org/classes/remotecontrol_handle.html
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- Deusdeorum
- Offline
- Senior Member
Less
More
- Posts: 72
- Thank you received: 17
7 years 3 months ago #145068
by Deusdeorum
Replied by Deusdeorum on topic Deactivate Survey with API
You could extend the API. However, I always use expire survey instead, and that can be done with the API in set_survey_settings()
The topic has been locked.
- bdrhoa
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
6 years 1 month ago #163054
by bdrhoa
Replied by bdrhoa on topic Deactivate Survey with API
Could you please post an example of how to expire a survey?
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3691
6 years 1 month ago - 6 years 1 month ago #163078
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Deactivate Survey with API
Using JSON-RPC, I think something like this (untested):
Code:
<?php require_once 'jsonRPCClient.php'; define( 'LS_BASEURL', 'http://pathTo/limeSurvey/'); define( 'LS_USER', 'username' ); define( 'LS_PASSWORD', 'password' ); $iSurveyID = 11111; if(ctype_alnum($iSurveyID) && (strlen($iSurveyID) == 5 || strlen($iSurveyID) == 6)) { // Valid SID format // Instantiate a new RPC client $myJSONRPCClient = new jsonRPCClient( LS_BASEURL.'/index.php/admin/remotecontrol' ); // Get a session key $sSessionKey= $myJSONRPCClient->get_session_key( LS_USER, LS_PASSWORD ); if(is_array($sSessionKey)) { // Invalid session echo $sSessionKey['status']; } else if($sSessionKey) { // Valid session // Expire survey $aSurveyData = array('expires'=>'2018-01-27 00:00:00'); $newSurveyProperties = $myJSONRPCClient->set_survey_properties($sSessionKey, $iSurveyID, $aSurveyData); } // Release the session key $myJSONRPCClient->release_session_key( $sSessionKey ); } else { // Invalid SID format die( 'Invalid format!' ); } ?>
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 6 years 1 month ago by tpartner.
The topic has been locked.