Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:

THEMA: Remote Control 2 - Export_responses

Remote Control 2 - Export_responses 1 Jahr 5 Monate her #88249

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: 1 Jahr 5 Monate her von rbauling0818. Begründung: forgot a line of code to make it make sense
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Remote Control 2 - Export_responses 1 Jahr 5 Monate her #88333

  • rawson
  • rawsons Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 4
  • Dank erhalten: 1
  • Karma: 1
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
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Remote Control 2 - Export_responses 1 Jahr 5 Monate her #88338

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
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Remote Control 2 - Export_responses 1 Jahr 5 Monate her #88341

  • rawson
  • rawsons Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 4
  • Dank erhalten: 1
  • Karma: 1
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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Remote Control 2 - Export_responses 1 Jahr 5 Monate her #88348

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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Remote Control 2 - Export_responses 1 Jahr 5 Monate her #88352

  • rawson
  • rawsons Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 4
  • Dank erhalten: 1
  • Karma: 1
Looks like a bug to me, you should put it into the bug tracker.
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: DenisChenu

Re: Remote Control 2 - Export_responses 1 Jahr 2 Monate her #91700

  • bebs
  • bebss Avatar
  • OFFLINE
  • Senior Lime
  • Beiträge: 48
  • Dank erhalten: 2
  • Karma: 0
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 );
 
?>
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Remote Control 2 - Export_responses 1 Jahr 2 Monate her #91846

  • mdekker
  • mdekkers Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 340
  • Dank erhalten: 68
  • Karma: 38
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
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: bebs

Re: Remote Control 2 - Export_responses 1 Jahr 2 Monate her #91855

  • bebs
  • bebss Avatar
  • OFFLINE
  • Senior Lime
  • Beiträge: 48
  • Dank erhalten: 2
  • Karma: 0
mdekker schrieb:
Try adding you survey language or null between 'csv' and 'all'

That was my problem, thanks very much!
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Moderatoren: ITEd
Ladezeit der Seite: 0.483 Sekunden
Donation Image