- Posts: 4
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
[
{
"933": {
"id": "933",
"submitdate": "2019-03-22 12:46:23",
"lastpage": "1",
"startlanguage": "en",
"token": "9bbc23aa75b7f325ff92cc430acba801ce6",
"startdate": "2019-03-22 12:44:46",
"datestamp": "2019-03-22 12:46:23",
"ipaddr": "127.0.0.1",
"refurl": "",
"FHNUS1": "No",
"FHNUS2": "",
"FHNUS3": "",
"FHNUS4": "N\/A",
"FHNUS5": null,
"FHNUS6": null,
"FHNUS7": null,
"FHNUS8": "N\/A",
"FHNUS9": "",
"FHNUS10": "",
"FHNUS11": "N\/A",
....,
"FHNUS90": ""
}
}
]
I looked into the code on GitHub, and saw that this method expects real columns names ({SURVEY_ID}X{QUESTION}) instead of what export_responses_by_token API returns to us.Error: Invalid Column names supplied: FHNUS1, FHNUS2, FHNUS3, FHNUS4, FHNUS5, FHNUS6, FHNUS7, FHNUS8, FHNUS9, FHNUS10, FHNUS11, ... , FHNUS90
<?php require_once 'jsonRPCClient.php'; define( 'LS_BASEURL', 'https://pathTo/limeSurvey'); define( 'LS_USER', 'admin' ); define( 'LS_PASSWORD', '*******' ); $iSurveyID = 885886; $sToken = '111'; 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 // Get a response by token $tokenResponse = $myJSONRPCClient->export_responses_by_token($sSessionKey, $iSurveyID, 'json', $sToken, null, 'all', 'code', 'long'); if(is_array($tokenResponse)) { // Oops, print any errors print_r($tokenResponse); } else { // There is a valid response... // Decode the retuned base-64 string and convert to an array $decodedString = base64_decode($tokenResponse); $tokenResponseArr = json_decode($decodedString, True); // Get the first item in the $tokenResponseArr['responses'][0] array $tokenResponseArr2 = reset($tokenResponseArr['responses'][0]); $responseID = $tokenResponseArr2['id']; echo $responseID; echo '<br /><br />'; // Update a response // In this case, we update a multiple-choice sub-question // and it's related comment with null values. // The group ID is 330, the question ID is 5152, the sq-code is SQ001 $aResponseData = array( 'id' => $responseID, $iSurveyID.'X330X5152SQ001' => '', $iSurveyID.'X330X5152SQ001comment' => '' ); $updatedResponse = $myJSONRPCClient->update_response($sSessionKey, $iSurveyID, $aResponseData); echo $updatedResponse; } } // Release the session key $myJSONRPCClient->release_session_key( $sSessionKey ); } else { // Invalid SID format die( 'Invalid format!' ); } ?>
It must not, last tested it work.tpartner wrote: @DenisChenu, are there any dependencies for rcAddReponseCode?
Seems that don't exist. tparner solution to set it to null is near the needed solution.ArtemPavlenko wrote: 2) Remove answers for specific survey and token from DB (???)