Welcome to the LimeSurvey Community Forum

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

End survey by click on URL

More
10 years 3 months ago #138094 by niolou
Hello,
  I'm trying to create a survey where the user would react to the satisfaction of solving his request.
The email have only two links:

Yes I was satisfied
url + ticketID + yes (web thank you for your rating)

I was not satisfied
url + ticketID + no (classical survey)

I know how to send parameters by url (index.php/436483?lang=cs&param1=TicketID&param2=yes)
I would like to closed the survey by clicking on the url and save the rating and I don´t know how?
Thank you for your advice
The topic has been locked.
More
10 years 3 months ago #138102 by tpartner
Replied by tpartner on topic End survey by click on URL
It seems to me that you should be using the RemoteControl 2 API with the add_response() method .

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
10 years 3 months ago #138161 by niolou
Replied by niolou on topic End survey by click on URL
It looks fine, but I don´t know how to use it.
I activate service RPC - JSON-RPC.
Could you send me example what next how to use method?
Thx
The topic has been locked.
More
10 years 3 months ago #138171 by tpartner
Replied by tpartner on topic End survey by click on URL
You would need to post to a PHP file that would insert the response via the API.

A simplified version of that PHP file would look something like this. The $param1Sgq and $param2Sgq variables are the database column names for the questions (or the SGQ values).

Code:
<?php require_once 'path/to/jsonRPCClient.php'; define( 'LS_BASEURL', 'https://path/to/limeSurvey/'); define( 'LS_USER', 'limesurvey_admin_name' ); define( 'LS_PASSWORD', 'limesurvey_admin_password' ); define( 'LS_DB_HOST', 'localhost' ); define( 'LS_DB_NAME', 'database_name' ); define( 'LS_DB_USER', 'database_user' ); define( 'LS_DB_PASS', 'database_password' ); define( 'LS_DB_TABLEPREFIX', 'lime_' ); // Define some vars $param1Sgq = '111111X22X333'; $param1Answer = $_POST['param1']; $param2Sgq = '111111X22X334'; $param2Answer = $_POST['param2']; $esgq = explode('X', $param1Sgq); $sid = $esgq[0]; if(ctype_alnum($sid) && strlen($sid) == 6) { // Valid SID format // Instantiate a new RPC client $myJSONRPCClient = new jsonRPCClient( LS_BASEURL.'/index.php/admin/remotecontrol' ); // Get a session key $sessionKey = $myJSONRPCClient->get_session_key( LS_USER, LS_PASSWORD ); // Build an array of response data $aResponseData = array($param1Sgq=>$param1Answer, $param2Sgq=>$param2Answer); // Add a response set $addResponse= $myJSONRPCClient->add_response($sessionKey, $sid, $aResponseData); // You could do something with the response ID here //echo $addResponse; // Release the session key $myJSONRPCClient->release_session_key( $sessionKey ); } 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.
The following user(s) said Thank You: Ben_V
The topic has been locked.
Moderators: tpartner, holch

Lime-years ahead

Online-surveys for every purse and purpose