Mixing Data Sources

More
2 months 3 weeks ago #177492 by davebostockgmail
Is it possible to use a token table AND panel integration .....

We have a project where we will get some of the data from a panel provider and some from the client.

The client sample will not have pass backs from quotas or at the end of the survey but the panel sample will.


Is it as easy as having 2 different quota qualifications set of the screenout 1) where the panel will be redirected to the provider and 2 where it will just close and then have a final screen that determines where the respondent ends up on completion ...

I am thinking a JQuery redirect for client data and the normal end of survey URL for the panel people ......

Has anyone done this before and if so is this how you did it or is there another way?

Thanks in advance

Please Log in or Create an account to join the conversation.

More
2 months 3 weeks ago - 2 months 3 weeks ago #177498 by DenisChenu
Replied by DenisChenu on topic Mixing Data Sources
I already do suche system
- autoCreate token plugin according to GET param …

Usage of beforeSurveyPage event .

I don't remind where this plugin was … maybe here : framagit.org/Shnoulle or here : framagit.org/SondagePro-LimeSurvey-plugin

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .
Last edit: 2 months 3 weeks ago by DenisChenu.

Please Log in or Create an account to join the conversation.

More
2 months 3 weeks ago - 2 months 3 weeks ago #177510 by davebostockgmail
Thank you Denis,

I could not find your plugin but it did give me an idea that seems to have solved the problem I was having.

For the Panel Participants I have used a PHP page that uses the panel ID passed in the link for the token and then generates this entry into the token table and redirects to the survey with the newly created panel ID.


Then in the survey I have used routing logic to determine the source of the respondent and pass them through to relevant quota stops ... when the respondent is from a panel it uses a redirect there to send them back to the panel as screened out and when it is client sample it just closes.

The only issue I have now is the end page ... for the sample from client I want to display the close message on submission and for the panel I want to redirect via a URL on completion ... so 2 different outcomes after submission of a survey ...

Any thoughts on this??

Here is the PHP I used for the initial stages in case it helps anyone else .. the token is passed by adding ?pid=Token on the end of the url
<?php
 
error_reporting(E_ALL);
ini_set('display_errors', 1); 
 
	require_once '../application/libraries/jsonRPCClient.php';
 
	define( 'LS_BASEURL', 'https://yourserver/index.php');  // adjust this one to your actual LimeSurvey URL
	define( 'LS_USER', 'yourname' );
	define( 'LS_PASSWORD', 'yourpassword' );
 
	$iSurveyID = yoursurveyID;
	$token = $_GET['pid']; ;
	$email = 'xxx@xxx.com';
	$FirstNameAPI = 'xxx' ;
	$LastNameAPI = 'Panel' ;
 
 
	// Instantiate a new RPC client
	$myJSONRPCClient = new jsonRPCClient( LS_BASEURL.'/admin/remotecontrol' );
 
	// Get a session key
	$sSessionKey= $myJSONRPCClient->get_session_key( LS_USER, LS_PASSWORD );
 
	// Define the token params
	$tokenParams = array("email"=>$email,"lastname"=>$LastNameAPI,"firstname"=>$FirstNameAPI,"token"=>$token,"language"=>'en',"emailstatus"=>"OK","attribute_1"=>"2");
	$aParticipantData=array($tokenParams);
	$bCreateToken = false;
 
	// Create the tokens
	$newToken = $myJSONRPCClient->add_participants( $sSessionKey, $iSurveyID, $aParticipantData, $bCreateToken);
 
	$newURL ="https://yourserver/index.php/survey/index/sid/yoursurveyID/token/".$token."/lang/en";
 
	// Release the session key
	$myJSONRPCClient->release_session_key( $sSessionKey );
	header('Location: '.$newURL);
?>
Last edit: 2 months 3 weeks ago by DenisChenu. Reason: Add code php
The following user(s) said Thank You: DenisChenu

Please Log in or Create an account to join the conversation.

More
2 months 3 weeks ago #177511 by davebostockgmail
And I should really try things first before posting ...

The end URL is as simple as putting an additional attribute field in the token table with the URL I want the participant to go to on completion

so I have an additional field - attribute_2 - that holds the end URL and then in the End URL field I simply place - {TOKEN:ATTRIBUTE_2} - This redirects the respondent dependent on the value in the token table.

Cheers
Dave
The following user(s) said Thank You: DenisChenu

Please Log in or Create an account to join the conversation.

More
2 months 3 weeks ago #177514 by DenisChenu
Replied by DenisChenu on topic Mixing Data Sources
Good idea with API, maybe better then my first idea :).

Else :
$token = $_GET; : i really don't like this …

Maybe
<?php
if(empy($_GET['pid'])) {
    die("You kill me");
}
$attribute1 = $_GET['pid'];
 
$aToken = $myJSONRPCClient->get_participant_properties($sSessionKey, $iSurveyID, array('attribute_1' => $attribute1));
$status = isset($aToken['status']) ? $aToken['status'] : null;
$token = isset($aToken['token']) ? $aToken['token'] : null;
if(empty($token)) {
    $tokenParams = array(
        array("email"=>"","lastname"=>$LastNameAPI,"firstname"=>$FirstNameAPI,"language"=>'en',"emailstatus"=>"OK","attribute_1"=>$attribute1,"attribute_2"=>"2")
    );
    $aToken = $myJSONRPCClient->add_participants($sSessionKey, $iSurveyID,$tokenParams);
    // add_participants seems broken currently (looking at code) , then get it
    $aToken = $myJSONRPCClient->get_participant_properties($sSessionKey, $iSurveyID, array('attribute_1' => $attribute1));
    $status = isset($aToken['status']) ? $aToken['status'] : null;
    $token = isset($aToken['token']) ? $aToken['token'] : null;
    if(empty($token) && !empty($status)) {
        die("I made an error in my code :".$status);
    }
}
$newURL ="https://example.org/index.php/survey/index/sid/".$iSurveyID."/token/".$token;
$myJSONRPCClient->release_session_key( $sSessionKey );
header('Location: '.$newURL);

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!