- Posts: 5
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Issue with redirecting out and back in from LS survey
- jsmatte1
- Topic Author
- Offline
- New Member
Less
More
1 year 1 month ago #241800
by jsmatte1
Issue with redirecting out and back in from LS survey was created by jsmatte1
Please help us help you and fill where relevant:
Your LimeSurvey version: Version 3.28.52
Own server or LimeSurvey hosting: LimeSurvey hosting
Survey theme/template: NA
==================
Hello LimeSurvey Community,
I have a survey in which respondents need to be directed to another url (Sawtooth conjoint experiment server), and then re-directed back into LS to complete the survey. I have found through this link and this link that it is possible, and implemented the code of the latter link. However, I am left with one issue: when the respondents are done with the part in Sawtooth and directed back to LS, they land on the question that directs them to Sawtooth in the first place. As if when the are redirected out of LS, it doesn't register that the respondent is done with that question and hence why they land at the exact same place instead of one step further.
The first link seems to have two actions built into it ('#movenextbtn, #movesubmitbtn'), but is for ls2, whereas the second link (the code I implemented) has only one ('#ls-button-submit'), but is for ls3. I am wondering if this is why it is not working, or if it is due to something else. The first link also refers to a config.php file in which the author added a bit of code. Since my survey is hosted by LimeSurvey, it is my understanding that I do not have access to that file. Is that where the problem comes from?
Any help is much appreciated!
Your LimeSurvey version: Version 3.28.52
Own server or LimeSurvey hosting: LimeSurvey hosting
Survey theme/template: NA
==================
Hello LimeSurvey Community,
I have a survey in which respondents need to be directed to another url (Sawtooth conjoint experiment server), and then re-directed back into LS to complete the survey. I have found through this link and this link that it is possible, and implemented the code of the latter link. However, I am left with one issue: when the respondents are done with the part in Sawtooth and directed back to LS, they land on the question that directs them to Sawtooth in the first place. As if when the are redirected out of LS, it doesn't register that the respondent is done with that question and hence why they land at the exact same place instead of one step further.
The first link seems to have two actions built into it ('#movenextbtn, #movesubmitbtn'), but is for ls2, whereas the second link (the code I implemented) has only one ('#ls-button-submit'), but is for ls3. I am wondering if this is why it is not working, or if it is due to something else. The first link also refers to a config.php file in which the author added a bit of code. Since my survey is hosted by LimeSurvey, it is my understanding that I do not have access to that file. Is that where the problem comes from?
Any help is much appreciated!
Please Log in to join the conversation.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12944
- Thank you received: 3979
1 year 1 month ago - 1 year 1 month ago #241803
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Issue with redirecting out and back in from LS survey
Hi,
1. The ID of this button was changed in version 3.x.
And as there is no real difference between the button ión the last page (where it says "Submit") and the button on previous pages, now there is only one ID (ls-button-submit).
2. It is easy to understand that this same page is displayed. You do not leave it.
You bind a different event to the button (to call the other location)
In the older thread you see how the TO queried the database to change the value of "lastpage".
As your installation is hosted at Limesurvey GMBH you have not access to the database.
So you have to think about a different approach.
An easy one:
Place the link to your Conjoint experiment in a question of type "text display"
Also in this question put a javascript snippet
While the respondent is doing the conjoint experiment this function triggers the "Next"click
Joffm
1. The ID of this button was changed in version 3.x.
And as there is no real difference between the button ión the last page (where it says "Submit") and the button on previous pages, now there is only one ID (ls-button-submit).
2. It is easy to understand that this same page is displayed. You do not leave it.
You bind a different event to the button (to call the other location)
In the older thread you see how the TO queried the database to change the value of "lastpage".
As your installation is hosted at Limesurvey GMBH you have not access to the database.
So you have to think about a different approach.
An easy one:
Place the link to your Conjoint experiment in a question of type "text display"
Also in this question put a javascript snippet
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ $('#ls-button-submit').hide(); setTimeout(function () { $('#ls-button-submit').trigger('click').show(); }, 30000); // Proceed after 30 seconds }); </script>
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 1 year 1 month ago by Joffm.
Please Log in to join the conversation.
- jelo
- Offline
- Platinum Member
Less
More
- Posts: 5033
- Thank you received: 1257
1 year 1 month ago #241812
by jelo
LimeSurvey seems lacking a few functions to better integrate third party websites into one survey.
Allow redirection during a survey and ensure that people reenter the survey via URL-link at a certain point (not always the last page saved by the session file).
I always used two survey with Sawtooth in between, which gave you headaches when you need to access data from the other survey.
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Replied by jelo on topic Issue with redirecting out and back in from LS survey
Wouldn't that allow a complete circumvention off the conjoint experiment?So you have to think about a different approach.
An easy one:
Place the link to your Conjoint experiment in a question of type "text display"
LimeSurvey seems lacking a few functions to better integrate third party websites into one survey.
Allow redirection during a survey and ensure that people reenter the survey via URL-link at a certain point (not always the last page saved by the session file).
I always used two survey with Sawtooth in between, which gave you headaches when you need to access data from the other survey.
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Please Log in to join the conversation.
- jsmatte1
- Topic Author
- Offline
- New Member
Less
More
- Posts: 5
- Thank you received: 0
1 year 1 month ago #241828
by jsmatte1
Replied by jsmatte1 on topic Issue with redirecting out and back in from LS survey
Hi Joffm,
I like your idea. However, I need to pass a token also to Sawtooth. Is there a way I can combine the approach used in the links I provided in my question, and your work around to ensure LS registers to go to the next question?
I like your idea. However, I need to pass a token also to Sawtooth. Is there a way I can combine the approach used in the links I provided in my question, and your work around to ensure LS registers to go to the next question?
Please Log in to join the conversation.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12944
- Thank you received: 3979
1 year 1 month ago #241831
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Issue with redirecting out and back in from LS survey
You add the token to the link the same way as shown in your scripts.
As usual:
www.mypage.com?para1=ABC¶2=123
And to answer @jelo:
Yes, I forgot that I some long time ago showed such a scenario with two surveys.
And, yes, you can circumvent the conjoint part. But this is done by intention, And these respondents to screenout.
And if you only show a button which links to the sawtooth part and hide the "Next" button, it should be neglectable.
Joffm
As usual:
www.mypage.com?para1=ABC¶2=123
And to answer @jelo:
Yes, I forgot that I some long time ago showed such a scenario with two surveys.
And, yes, you can circumvent the conjoint part. But this is done by intention, And these respondents to screenout.
And if you only show a button which links to the sawtooth part and hide the "Next" button, it should be neglectable.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Please Log in to join the conversation.
- jsmatte1
- Topic Author
- Offline
- New Member
Less
More
- Posts: 5
- Thank you received: 0
1 year 1 month ago #241859
by jsmatte1
Replied by jsmatte1 on topic Issue with redirecting out and back in from LS survey
FYI, your suggestion does not seem to work. Implemented it but it looks like the timer stops when respondents leaves LS to go to Sawtooth, and lands again on the same LS page, then has to wait 30s. for the auto click to happen.
Only way I can make it work is if the link to Sawtooth opens in a new tab, such that the LS page remains open until the auto trigger clicks to next.
Only way I can make it work is if the link to Sawtooth opens in a new tab, such that the LS page remains open until the auto trigger clicks to next.
Please Log in to join the conversation.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12944
- Thank you received: 3979
1 year 1 month ago #241860
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Issue with redirecting out and back in from LS survey
How did you implement it?
Show it
Send a lss export of the protzotype!
Joffm
Show it
Send a lss export of the protzotype!
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Please Log in to join the conversation.
- jsmatte1
- Topic Author
- Offline
- New Member
Less
More
- Posts: 5
- Thank you received: 0
1 year 1 month ago #241861
by jsmatte1
Replied by jsmatte1 on topic Issue with redirecting out and back in from LS survey
This is the work around I have come up with. However, when I run the question preview, it behaves as expected and redirects to Sawtooth, whereas when I preview the survey, it stays on the question page...
Code:
<p>Please click to be redirected to the choice tasks.</p> <button>Go to choice tasks</button><script> $(document).ready(function() { var idnum=1234; // var idnum="{TOKEN:TOKEN}"; var url="https://mystudy.com/cgi-bin/ciwweb.pl?studyname=mystudy&amp;panelid="+idnum; $('#ls-button-submit').hide(); $('button').click(function () { $('#ls-button-submit').trigger('click').show() $(location).attr("href", url); return false; }); }); </script>
Please Log in to join the conversation.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12944
- Thank you received: 3979
1 year 1 month ago - 1 year 1 month ago #241862
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Issue with redirecting out and back in from LS survey
Yes, this is your old approach.
But I proposed this.
Adapt to your needs.
But I proposed this.
Code:
<a class="btn btn-primary btn-lg active" href="http://www.server.de?panelid={SAVEDID}" role="button" target="_blank">Please, click to enter the experiment</a> <script type="text/javascript" charset="utf-8"> $(document).ready(function(){ $('#ls-button-submit').hide(); setTimeout(function () { $('#ls-button-submit').trigger('click').show(); }, 30000); // Proceed after 30 seconds }); </script>
Adapt to your needs.
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 1 year 1 month ago by Joffm.
Please Log in to join the conversation.
- jsmatte1
- Topic Author
- Offline
- New Member
Less
More
- Posts: 5
- Thank you received: 0
1 year 1 month ago #241869
by jsmatte1
Replied by jsmatte1 on topic Issue with redirecting out and back in from LS survey
Hi Joffm,
Yes, but as I mentioned previously, your proposed method only works if you open a new tab when redirecting outside of LS. I see that you added target="_blank" for that, but it is not the cleanest way to do it as you will have two tabs open, and as someone else pointed out, this could make respondents circumvent the choice tasks altogether.
Is there a way this could work without the target="_blank"?
Yes, but as I mentioned previously, your proposed method only works if you open a new tab when redirecting outside of LS. I see that you added target="_blank" for that, but it is not the cleanest way to do it as you will have two tabs open, and as someone else pointed out, this could make respondents circumvent the choice tasks altogether.
Is there a way this could work without the target="_blank"?
Please Log in to join the conversation.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10110
- Thank you received: 3593
1 year 1 month ago #241870
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Issue with redirecting out and back in from LS survey
An alternative may be to redirect to an intermediate PHP page before redirecting to Sawtooth. This PHP page could use the API to increment (or change) the "lastpage" value of the response so when the respondent returns to the survey after Sawtooth (via token response persistence) they land at a new "lastpage".
A note: To update the response via the update_response() method, you will also need to enable "Allow multiple responses or update responses with one token" - manual.limesurvey.org/Participant_settin...onses_with_one_token .
Here is a small PHP example which:
- Uses the export_responses_by_token() method to determine the response ID and lastpage values.
- Increments the lastpage value.
- Uses the update_response() method to modify the lastpage value.
- Redirects to another webpage.
A note: To update the response via the update_response() method, you will also need to enable "Allow multiple responses or update responses with one token" - manual.limesurvey.org/Participant_settin...onses_with_one_token .
Here is a small PHP example which:
- Uses the export_responses_by_token() method to determine the response ID and lastpage values.
- Increments the lastpage value.
- Uses the update_response() method to modify the lastpage value.
- Redirects to another webpage.
Code:
<?php require_once 'jsonRPCClient.php'; define( 'LS_BASEURL', 'http://localhost/limeSurvey3x'); define( 'LS_USER', 'admin' ); define( 'LS_PASSWORD', 'password' ); $iSurveyID = $_GET['sid']; $sToken = $_GET['token']; if(ctype_alnum($iSurveyID) && (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 // Get a response by token to determine the response ID and lastpage values $aFields = array('id', 'lastpage'); $tokenResponse = $myJSONRPCClient->export_responses_by_token($sSessionKey, $iSurveyID, 'json', $sToken, null, 'all', 'code', 'short', $aFields); if(is_array($tokenResponse)) { // Oops, a response error... // Print any errors print_r($tokenResponse); // Release the session key $myJSONRPCClient->release_session_key( $sSessionKey ); } // else { // There is a valid response... // Decode the returned base-64 string and convert to an array $decodedString = base64_decode($tokenResponse); $tokenResponseArr = json_decode($decodedString, True); // Get the first item in the $tokenResponseArr['responses'][0] array $tokenResponseArr2 = reset($tokenResponseArr['responses'][0]); // Define vars for the response ID and lastpage values $responseID = $tokenResponseArr2['id']; $responseLastpage = $tokenResponseArr2['lastpage']; // Increment the lastpage // ...or, you could hard-code a lastpage value here instead $responseLastpage++; // Update the response lastpage value $aResponseData = array( 'id' => $responseID, 'lastpage' => $responseLastpage ); $updatedResponse = $myJSONRPCClient->update_response($sSessionKey, $iSurveyID, $aResponseData); // Release the session key $myJSONRPCClient->release_session_key( $sSessionKey ); // Redirect to the next site header("Location: https://google.com"); die(); } } } 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: DenisChenu
Please Log in to join the conversation.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13647
- Thank you received: 2491
1 year 3 weeks ago #241998
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Issue with redirecting out and back in from LS survey
@tpartner : i think you need Increments the lastpage value by 2, because it was set to the previous page, not current.
See gitlab.com/SondagesPro/coreAndTools/KeepCurrentStep
See gitlab.com/SondagesPro/coreAndTools/KeepCurrentStep
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Please Log in to join the conversation.