Welcome to the LimeSurvey Community Forum

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

Adding Welcome Message via the Remote Control API

  • SimonPressler
  • SimonPressler's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 7 months ago #241795 by SimonPressler
Please help us help you and fill where relevant:
Your LimeSurvey version:  5.6.11
Own server or LimeSurvey hosting: LimeSurvey hosting
Survey theme/template: fruity
==================
Dear Forum,
i have been using the API a lot lately, but i cannot locate the option to add a welcome text / description to the survey via API.
Is this possible, or should i stop searching?
Thanks in advance and best regards
Simon

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 7 months ago #241804 by tpartner
You are looking for the set_language_properties() method - api.limesurvey.org/classes/remotecontrol..._language_properties .

Here is a quick PHP example:

Code:
<?php
 
  require_once 'jsonRPCClient.php';
 
  define( 'LS_BASEURL', 'https://localhost/limeSurvey5x');  
  define( 'LS_USER', 'admin' );
  define( 'LS_PASSWORD', 'password' );
 
  $iSurveyID = 392446;
 
 
  if(ctype_alnum($iSurveyID) &amp;&amp; (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
 
      $newTitle = 'TEST SURVEY 1';
      $newDescription = 'Some survey description...';
      $newWelcomeMsg = '<p style="font-weight: bold;">Some welcome message.</p><p>And, another paragraph.</p>';
      $newEndMsg = 'Some end message...';
 
      $aSurveyLocaleData = array(
        'surveyls_title'  => $newTitle,
        'surveyls_description' => $newDescription,
        'surveyls_welcometext' => $newWelcomeMsg,
        'surveyls_endtext' => $newEndMsg
      );
 
      $sLanguage = 'en';
 
      $newLanguageProperties = $myJSONRPCClient->set_language_properties($sSessionKey,  $iSurveyID, $aSurveyLocaleData, $sLanguage);
 
      print_r($newLanguageProperties);
    }
 
    // Release the session key
    $myJSONRPCClient->release_session_key( $sSessionKey );
  }
  else { // Invalid SID format
    die( 'Invalid format!' );
  }
 
?>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

  • SimonPressler
  • SimonPressler's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 7 months ago #241807 by SimonPressler
Replied by SimonPressler on topic Adding Welcome Message via the Remote Control API
Once again, thank you very much!

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose