Remote Control 2 - Export_responses

Mehr
5 Jahre 8 Monate her - 5 Jahre 8 Monate her #88249 von rbauling0818
rbauling0818 erstellte das Thema Remote Control 2 - Export_responses
Hello,

I'm using LimeSurvey Version 2.00+ Build 121115 and I'm trying to get the export_responses function to work, but I keep getting an error. It may be an error on my part, but I'm not sure.

Here's my code
require_once 'jsonRPCClient.php';
 
define( 'LS_BASEURL', 'limesurveyurl');
define( 'LS_USER', 'admin' );
define( 'LS_PASSWORD','password' )
 
$survey_id=96293;
$sSurveyLanguage = 'en';
$status = 'all';
$heading = 'code';
$responseType = 'short';
$doc_type= 'csv';
 
$myJSONRPCClient = new jsonRPCClient( LS_BASEURL.'/admin/remotecontrol' );
$sSessionKey= $myJSONRPCClient->get_session_key( LS_USER, LS_PASSWORD );
 
$export_responses = $myJSONRPCClient->export_responses($sSessionKey, $survey_id, $doc_type, $sSurveyLanguage, $status, $heading, $responseType);
 

I keep getting this error when I get it to work: [status] => Error: No Permission or I get an error thrown form the jsonRPCClient file.

Does anyone have any insight into this?
Letzte Änderung: 5 Jahre 8 Monate her von rbauling0818. Begründung: forgot a line of code to make it make sense

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
5 Jahre 8 Monate her #88333 von rawson
rawson antwortete auf das Thema: Remote Control 2 - Export_responses
I tried this and also got an error, is this the same error that you're getting?
Fatal error: Uncaught exception 'Exception' with message 'Request error: CDbCommand failed to execute the SQL statement: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' in jsonrpcphp\jsonRPCClient.php on line 155 Exception: Request error: CDbCommand failed to execute the SQL statement: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'return ORDER BY `lime_survey_854479`.`id` LIMIT 1' at line 4 in jsonrpcphp\jsonRPCClient.php on line 155

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
5 Jahre 8 Monate her #88338 von rbauling0818
rbauling0818 antwortete auf das Thema: Remote Control 2 - Export_responses
I did get that error initially, but when I upgraded it was fixed in one of the bugs. Still doesn't seem to make it work though. I keep getting this error:
Exception: Incorrect response id (request id: 1, response id: )

Here's the bug in case you're wondering:
Export Responses Bug

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
5 Jahre 8 Monate her #88341 von rawson
rawson antwortete auf das Thema: Remote Control 2 - Export_responses
After updating I started getting the same error, until I went to my limesurvey admin page which prompted me to update the database. After clicking on the button to update the database I now get the following error:
Request error: unknown method or incorrect parameters

I will try fiddling with the parameters to see if I can get it to work.

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
5 Jahre 8 Monate her #88348 von rbauling0818
rbauling0818 antwortete auf das Thema: Remote Control 2 - Export_responses
Hmm I got that error too depending on what you put into the $doc_type variable the error changes and if you take out the survey id it won't give you the php error it'll return
Array{[status] => No Permission]}

I never got it to work tried all day yesterday.

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
5 Jahre 8 Monate her #88352 von rawson
rawson antwortete auf das Thema: Remote Control 2 - Export_responses
Looks like a bug to me, you should put it into the bug tracker.
Folgende Benutzer bedankten sich: DenisChenu

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
5 Jahre 5 Monate her #91700 von bebs
bebs antwortete auf das Thema: Remote Control 2 - Export_responses
Hello.

fyi the code below works fine to me (v20130118) and forces the download of a csv file that contains the answer metadata ("id","Completed","Last page","Start language","Date started","Date last action","IP address","Referring URL").

thank you devs.

Unfortunately (to me) I'm looking for a way to export all the answers for a given survey and answer "id" remotely. Is there any possibility yet?

Thanks. B.
<?php
require_once 'includes/jsonRPCClient.php';
 
define( 'LS_BASEURL', 'http://limesurvey.localhost/index.php');  // adjust this one to your actual LimeSurvey URL
define( 'LS_USER', 'rpcuser' );
define( 'LS_PASSWORD', 'rpcpass' );
 
// the survey to process
$survey_id=326549;
 
// instanciate a new client 
$myJSONRPCClient = new jsonRPCClient( LS_BASEURL.'/admin/remotecontrol' );
 
// receive session key
$sessionKey= $myJSONRPCClient->get_session_key( LS_USER, LS_PASSWORD );
 
//export answers
$responses = $myJSONRPCClient->export_responses( $sessionKey, $survey_id, 'csv', 'all', 'code', 'long');
header('Content-Disposition: attachment;filename="answers_data.csv"');
header('Content-Type: application/force-download'); 
print_r(base64_decode($responses), null);
 
// release the session key
$myJSONRPCClient->release_session_key( $sessionKey );
 
?>

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
5 Jahre 5 Monate her #91846 von mdekker
mdekker antwortete auf das Thema: Remote Control 2 - Export_responses
Try adding you survey language or null between 'csv' and 'all'

This is the signature:

/**
* RPC Routine to export responses.
* Returns the requested file as base64 encoded string
*
* @access public
* @param string $sSessionKey Auth credentials
* @param int $iSurveyID Id of the Survey
* @param string $sDocumentType pdf,csv,xls,doc
* @param string $sLanguageCode The language to be used
* @param string $sCompletionStatus Optional 'complete','incomplete' or 'all' - defaults to 'all'
* @param string $sHeadingType 'code','full' or 'abbreviated' Optional defaults to 'code'
* @param string $sResponseType 'short' or 'long' Optional defaults to 'short'
* @param integer $iFromResponseID Optional
* @param integer $iToResponseID Optional
* @param array $aFields Optional Selected fields
* @return array|string On success: Requested file as base 64-encoded string. On failure array with error information
* */
public function export_responses($sSessionKey, $iSurveyID, $sDocumentType, $sLanguageCode=null, $sCompletionStatus='all', $sHeadingType='full', $sResponseType='short', $iFromResponseID=null, $iToResponseID=null, $aFields=null)

---
Menno Dekker
Folgende Benutzer bedankten sich: bebs

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Mehr
5 Jahre 5 Monate her #91855 von bebs
bebs antwortete auf das Thema: Remote Control 2 - Export_responses

mdekker schrieb: Try adding you survey language or null between 'csv' and 'all'


That was my problem, thanks very much!

Bitte Anmelden oder Registrieren um an der Konversation teilzunehmen.

Jetzt loslegen!

Melden Sie sich jetzt an, und erstellen Sie in wenigen Minuten Ihre erste Umfrage.

Account einrichten

Abonnieren Sie unseren Newsletter

Abonnieren Sie unseren Newsletter für alle Neuigkeiten rund um LimeSurvey
captcha