Welcome to the LimeSurvey Community Forum

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

Redirect to second survey then continue with first survey

  • davebostockgmail
  • davebostockgmail's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
6 years 3 months ago - 6 years 3 months ago #162206 by davebostockgmail
I am not sure if this is needed by anyone else but I thought I would share this with you all, you know just in case.

We have a client that wanted to do an adaptive conjoint section within their survey and by within I mean right in the middle .. if they wanted to do it at the end no big deal as I could have used the end URL redirect to accomplish this, but no .. it had to be in the middle section ... so with the help of other posts from here and a little fiddling around I came up with a solution that allows the respondent to start the survey in Limesurvey ... then jump to a Conjoint survey in Sawtooth ... and then jump back into the half completed survey in Limesurvey to finish the task.

Like I said this may or may not help anyone out there but as with all these things I thought I would share.

To accomplish this I did the following ...

1) Set up the survey to use Tokens (This will be the ID that I can use to match data and also restart the survey where they left off)
2) Set Enable Token Based Persistence in General Settings to Yes
3) Create a Text Display question with "You will be now sent to an exercise where ...." and in the source of this question add in the following ....

<script>
$(document).ready(function() {

var idnum={TOKEN:TOKEN};
var url='https://xxxxx/maxdiff.php?token='+idnum;

$('#movenextbtn, #movesubmitbtn').bind('click', function () {
$(location).attr("href", url);
return false;
});

});
</script>

This points to a PHP file on our server which is important .... the php file contains the following ...

<?php
include("Config.php");
session_start();
$token=mysqli_real_escape_string($db,$_GET);
$quota=mysqli_real_escape_string($db,$_GET);

$sql= "UPDATE survey_731351 SET lastpage='44' WHERE token='$token' and lastpage='42'";
$result=mysqli_query($db,$sql);

header("location: https://xxx/cgi-bin/ciwweb.pl?hid_studyname=J46567&r={$token}");
?>

The last page ='42' is the number of the text display question and this is moved on 2 places to a new display welcoming the respondent back ... why 2 I know not I did experiment with adding one more page so 43 but this failed to work as expected.

The Config.php contains the log in information for the MySQL database for this survey .. the second website here is the Sawtooth server and the survey that captures the token ID ...

At the end of the Sawtooth exercise I redirect from that survey back to Limesurvey with the following URL

https://xxx/index.php/survey/index?sid=731351&token=[IDNumber]&newtest=Y

again where xxx is your survey etc.

We have done this now on more than one occasion and I know it took me a while to work out how to get there but it does work and hopefully it will help someone else out if they every come across a need for this.
Last edit: 6 years 3 months ago by davebostockgmail.
The topic has been locked.
More
6 years 3 months ago #162211 by jelo
Nice idea. Not many use Sawtooth in combination with LimeSurvey.
I use two LimeSurvey surveys and put Sawtooth inbetween.
Which works with or without token.
I wonder, if that whole PHP/MySQL can be left out, when using an additional URL parameter which skips the group with the javascript redirection when reentering the LS survey again.

Which version of LS do you use for this workaround?

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
  • davebostockgmail
  • davebostockgmail's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
6 years 3 months ago #162212 by davebostockgmail
Replied by davebostockgmail on topic Redirect to second survey then continue with first survey
It is the lts version before the fancy 2.5 so 2.06 I think.

The reason we do the SQL is so that we can have all the non Sawtooth data in one data set and all our surveys are closed so it is less work in setting up the token tables and monitoring true completes counts
The topic has been locked.
More
6 years 3 months ago #162215 by jelo

davebostockgmail wrote: It is the lts version before the fancy 2.5 so 2.06 I think.

Fancy ;-) The new version scheme had an impact on LTS too.
The LTS 2.06 is Limesurvey 2.6.6+ 171111. So the latest LTS was released on 11th Nov. 2017.

You called the PHPscript maxdiff.php but mentioned a "adaptive conjoint section". Was it a MaxDiff exercise?
LS 3.0 will allow more customizing with the questionlayout. Still a long way to get different experiments plans for every respondent like in Sawtooth.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose