Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Copy a survey using remotecontrol

  • roblej
  • roblej's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 months 4 weeks ago #267194 by roblej
Copy a survey using remotecontrol was created by roblej
Please help us help you and fill where relevant:
Your LimeSurvey version: LimeSurvey Community Edition, Versión 5.6.26+230613
Own server or LimeSurvey hosting: Own server
Survey theme/template:
==================
Hello
I am trying to create a script to copy a survey using remotecontrol. I have installed the jsonrpcphp library in this directory: /code/limesurvey/third_party/jsonrpcphp 
 
and I include it in my script:
require_once __DIR__ . '/../../third_party/jsonrpcphp/src/org/jsonrpcphp/JsonRPCClient.php';
 
I set the address and access parameters:
define( 'LS_RPCURL', ' mysite.com/index.php/admin/remotecontrol ');  
define( 'LS_USER', 'admin' );
define( 'LS_PASSWORD', 'mypassword' );
 
I create the client:
$myJSONRPCClient = new $myJSONRPCClient( LS_RPCURL );
 
I create the session key:
$sessionKey= $myJSONRPCClient->get_session_key( LS_USER, LS_PASSWORD );
  
And run the function to copy a poll from another one:
$result = $myJSONRPCClient->copy_survey($sessionKey, 111, 'Copy survey 111');
  
I also need to set the ID of the new survey. According to the documentation ( api.limesurvey.org/classes/remotecontrol...l#method_copy_survey ), it is possible to send another parameter with the ID of the new survey:

 $result = $myJSONRPCClient->copy_survey($sessionKey, 111, 'Copy survey 111', 222);

But it doesn't work... It creates the survey with a different ID than desired (222 in the example). In the documentation ( api.limesurvey.org/classes/remotecontrol...l#method_copy_survey ), it says that the file remotecontrol_handle.php is in the path application/helpers/remotecontrol. But when editing the file, I see that the copy_survey function does not receive that fourth parameter: the id of the new poll:
 
public function copy_survey($sSessionKey, $iSurveyID_org, $sNewname).
 
Maybe I don't have the correct version of remotecontrol_handle.php?

Thanks for your help

Please Log in to join the conversation.

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
3 months 3 weeks ago - 3 months 3 weeks ago #267218 by DenisChenu
Replied by DenisChenu on topic Copy a survey using remotecontrol
> I see that the copy_survey function does not receive that fourth parameter: the id of the new poll:

You compare : github.com/LimeSurvey/LimeSurvey/blob/ma...tecontrol_handle.php
For 5.X version : github.com/SondagesPro/LimeSurvey-Sondag...tecontrol_handle.php

Check new feature : github.com/LimeSurvey/LimeSurvey/blob/ma...cs/release_notes.txt

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
Last edit: 3 months 3 weeks ago by DenisChenu.

Please Log in to join the conversation.

  • roblej
  • roblej's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 months 3 weeks ago #267220 by roblej
Replied by roblej on topic Copy a survey using remotecontrol
Thank you very much Denis. It has worked very well.

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose