- Posts: 2
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
SXGXQ1 = 'A1', SXGXQ2 = 'A2', SXGXQ3 = 'A3', SXGXQ4 = 'A4'
<?php require_once 'jsonRPCClient.php'; define( 'LS_BASEURL', 'https://pathTo/limesurvey/'); define( 'LS_USER', 'admin' ); define( 'LS_PASSWORD', 'password' ); $iSurveyID = 123456; $g1ID = 123; $q1ID = 1234; $q1SGQ = $iSurveyID.'X'.$g1ID.'X'.$q1ID; 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 // Set a new response $aResponseData = array($q1SGQ.'1'=>'A1', $q1SGQ.'2'=>'A2', $q1SGQ.'3'=>'A3', $q1SGQ.'4'=>'A4'); $newResponse = $myJSONRPCClient->add_response($sSessionKey, $iSurveyID, $aResponseData); } // Release the session key $myJSONRPCClient->release_session_key( $sSessionKey ); } else { // Invalid SID format die( 'Invalid format!' ); } ?>