Welcome, Guest
Username: Password: Remember me

TOPIC: Saving to LS, but submitting to an external site

Saving to LS, but submitting to an external site 2 years 7 months ago #77805

  • tacman1123
  • tacman1123's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 125
  • Karma: 1
I'm trying to use Limesurvey to deploy an Amazon Turk Task. I'm trying to figure out how to submit my answers to Turk, but make sure they're saved to the LS database, and that all the LS housecleaning is done (like marking tokens as being used, marking the survey as complete, etc.)

I'm thinking I can change the POST action in the template to go to Turk, if the onSubmit action does an AJAX save of all the data. Or there are probably other solutions, I'm not sure if it's possible to do a redirect to a POST with all the data (or even a GET for that matter).

Tac
The administrator has disabled public write access.

Re: Saving to LS, but submitting to an external site 2 years 7 months ago #77858

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6551
  • Thank you received: 868
  • Karma: 257
Hello,

You can use your own script at end of the survey. (see endurl)
Take the id of the answer with GET or ( best) with SESSION.

The take the answers and fill your own database.
No need of ajax here.

Denis
The administrator has disabled public write access.

Re: Saving to LS, but submitting to an external site 2 years 7 months ago #77862

  • tacman1123
  • tacman1123's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 125
  • Karma: 1
When I fill in endurl, it simply gives me that as a link after the page that says "Thank you! Your survey responses have been recorded.". No GET params, not sure about session.

Is there something else to set to have it redirect, with the survey_id and response_id? That'd be great, I can probably figure it out from there.

Tac
The administrator has disabled public write access.

Re: Saving to LS, but submitting to an external site 2 years 7 months ago #77864

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6551
  • Thank you received: 868
  • Karma: 257
See #12 in docs.limesurvey.org/Creating+a+new+surve...ation_amp_navigation

And in end url you can use www.example.org/myscript.php?savedid={SAVEDID}

docs.limesurvey.org/URL+fields&highlight=SAVEDID

Then you can do what you want in myscript.php (even get the SESSION of the survey).

Denis
The administrator has disabled public write access.

Re: Saving to LS, but submitting to an external site 2 years 7 months ago #77931

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5423
  • Thank you received: 307
  • Karma: 252
Tac, can you describe the workflow with Amazon Turk and how it should be integrated/connected to Limesurvey?
You should also enable the auto load of the end URL.

Denis, isn't the session usually destroyed after submitting results?

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.

Re: Saving to LS, but submitting to an external site 2 years 7 months ago #77938

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6551
  • Thank you received: 868
  • Karma: 257
Mazi wrote:
Denis, isn't the session usually destroyed after submitting results?
Not with autoload url[*] OR user can print there answer.

Denis
*: need some test ;)
The administrator has disabled public write access.

Re: Saving to LS, but submitting to an external site 2 years 6 months ago #79194

  • hrshdhgd
  • hrshdhgd's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 29
  • Karma: 0
I am going through a similar issue as discussed in this thread. I am trying to link Amazon Mechanical Turk (MTurk) to a LS survey which then is directed to a web application designed by me. This is how Mturk and LS are connected.

I have used the 'Command Line Tools' feature of MTurk, wherein the survey (in MTurk) is designed in an XML format. So what MTurk basically does is embeds LimeSurvey in its webpage (using iframe tags) I have added code in LS (using Jscript and HTML) to get certain data values (namely workerId, assignmentId etc) which is available in the url to the main MTurk Page.

Now I need to pass on this same data from LimeSurvey to my web application. The problems I have faced so far:

1) When I use the endURL feature (#12 to the link mentioned by Denis), the data does not get transferred to my web application at all!(workerId, assignmentId etc).

2) when is use <form> tags for e.g.
<form id="mturk_form" method="POST" action ="https://address-to-my-web-app">

in the startpage.pstpl of my LimeSurvey, it transfers the data perfectly to my web application but the responses to the questions asked in LimeSurvey are not populated in the LimeSurvey database.

Note: My survey in LS are is one page long. I have turned the 'Welcome Page' = off and the 'complete page' also does not show because of the <form> tag 'post'ing the data to my web application directly thus bypassing the display of the 'complete page'.

I have been struggling with this for over a week and am out of ideas.
Any help would be greatly appreciated!

Thanks,
H.
Last Edit: 2 years 6 months ago by hrshdhgd.
The administrator has disabled public write access.

Re: Saving to LS, but submitting to an external site 2 years 6 months ago #79425

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5423
  • Thank you received: 307
  • Karma: 252
hrshdhgd wrote:
2) when is use <form> tags for e.g.
<form id="mturk_form" method="POST" action ="https://address-to-my-web-app">

in the startpage.pstpl of my LimeSurvey, it transfers the data perfectly to my web application but the responses to the questions asked in LimeSurvey are not populated in the LimeSurvey database.
That is a technical problem. A FORM tag can only direct to one page, so if you add yor own form tag on the same page, the Limesurvey forms will not be submitted because your form points to a different web page which doesn't contain the code to process the Limesurvey FORM elements.

Using the auto load end URL would be my feature of choice. Can you explain in more detail why this doesn't work for you?
Did you activate the survey?
How does your end URL look like?
Coud the problem be related to using an iFrame?

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.

Re: Saving to LS, but submitting to an external site 2 years 6 months ago #79439

  • hrshdhgd
  • hrshdhgd's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 29
  • Karma: 0
Hey Mazi,

The survey is active.
My end URL is "https://address-to-web-app/task.php. "
The redirect to the web app using end URL is smooth and the problem is that the info does not get transferred.
I am not sure about iFrame creating the issue but I guess not.

I know what the problem is. The survey's 'question page' passes the information like workerId etc using the following code:
<input type="hidden" name="workerId" value="(gets-it-through-javascript)">

But when it is passed to the completed page, the information is not assigned a variable there (in the 'completed page') and so the information in turn is not passed to the web app. I am sure the 'question page' is passing the data since I have tested it using my web app.

I tried passing the code:
<?php $workerId = $_POST['workerId'] ?>
<input type="hidden" name="workerId" value="<?php echo $workerId;?>">

in the 'startpage.pstpl' of 'completed page' to assign workerId a variable. But when I save changes in the 'completed page', the'<' from <?php disappears. I don't know why that is happening.

So the solution to this problem is if you could help me pass the information from the 'question page' to the 'completed page' and then I could take it from there!

Thanks,
H.
Last Edit: 2 years 6 months ago by hrshdhgd.
The administrator has disabled public write access.

Re: Saving to LS, but submitting to an external site 2 years 6 months ago #79451

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5423
  • Thank you received: 307
  • Karma: 252
1. You can't just add PHP code at a template file for security reasons!

2. Your end URL should look like "www.somedomain.org/task.php?value1={INSE...SERTANS:12345X22X334}..."

See end URL: docs.limesurvey.org/Creating+a+new+surve...r+LimeSurvey#General

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.254 seconds
Donation Image