Saving to LS, but submitting to an external site

More
5 years 2 months ago #77805 by tacman1123
tacman1123 created the topic: Saving to LS, but submitting to an external site
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

Please Log in to join the conversation.

More
5 years 2 months ago #77858 by DenisChenu
DenisChenu replied the topic: Saving to LS, but submitting to an external site
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

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 to join the conversation.

More
5 years 2 months ago #77862 by tacman1123
tacman1123 replied the topic: Saving to LS, but submitting to an external site
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

Please Log in to join the conversation.

More
5 years 2 months ago #77864 by DenisChenu
DenisChenu replied the topic: Saving to LS, but submitting to an external site
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

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 to join the conversation.

More
5 years 2 months ago #77931 by Mazi
Mazi replied the topic: Saving to LS, but submitting to an external site
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)survey-consulting.com'"

Please Log in to join the conversation.

More
5 years 2 months ago #77938 by DenisChenu
DenisChenu replied the topic: Saving to LS, but submitting to an external site

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 ;)

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 to join the conversation.

More
5 years 2 months ago - 5 years 2 months ago #79194 by hrshdhgd
hrshdhgd replied the topic: Saving to LS, but submitting to an external site
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: 5 years 2 months ago by hrshdhgd.

Please Log in to join the conversation.

More
5 years 1 month ago #79425 by Mazi
Mazi replied the topic: Saving to LS, but submitting to an external site

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)survey-consulting.com'"

Please Log in to join the conversation.

More
5 years 1 month ago - 5 years 1 month ago #79439 by hrshdhgd
hrshdhgd replied the topic: Saving to LS, but submitting to an external site
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: 5 years 1 month ago by hrshdhgd.

Please Log in to join the conversation.

More
5 years 1 month ago #79451 by Mazi
Mazi replied the topic: Saving to LS, but submitting to an external site
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)survey-consulting.com'"

Please Log in to join the conversation.

More
5 years 1 month ago - 5 years 1 month ago #79452 by hrshdhgd
hrshdhgd replied the topic: Saving to LS, but submitting to an external site
I thought about doing that. But isn't INSERTANS a variable assigned to one of the responses to a question asked in LS? The data I need to pass is hidden throughout the time LS is passing it and not one of the responses in the survey. the workerId is assigned by Amazon Mechanical Turk which is passed as a 'hidden' variable.

Thanks,
H.
Last Edit: 5 years 1 month ago by hrshdhgd.

Please Log in to join the conversation.

More
5 years 1 month ago #79456 by Mazi
Mazi replied the topic: Saving to LS, but submitting to an external site
You are right, but you can simply populate question at Limesurvey by URL so storing e. g. the worker ID at a hidden question and then passing that value back using the end URL as described should do the trick for you.


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

More
5 years 1 month ago #79458 by hrshdhgd
hrshdhgd replied the topic: Saving to LS, but submitting to an external site
Sounds like a great plan!! How do I go about doing that?

Please Log in to join the conversation.

More
5 years 1 month ago #79473 by Mazi
Mazi replied the topic: Saving to LS, but submitting to an external site
Have a look at the documentation on end URL and SGQA:
docs.limesurvey.org/Creating+a+new+surve...tions+for+LimeSurvey

docs.limesurvey.org/SGQA+identifier&stru...tions+for+LimeSurvey


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

More
5 years 1 month ago - 5 years 1 month ago #79664 by hrshdhgd
hrshdhgd replied the topic: Saving to LS, but submitting to an external site
I now understand how the SGQA and end URL work. How do I get the workerId to save as an answer to a hidden question? Do I have to use Javascript for doing that? I am not very familiar with Javascript. Any help would be greatly appreciated! I tried the following code
<script language="Javascript">
	function gup( name )
		{
		  var regexS = "[\\?&]"+name+"=([^&#]*)";
		  var regex = new RegExp( regexS );
		  var tmpURL = window.location.href;
		  var results = regex.exec( tmpURL );
		  if( results == null )
		    return "";
		  else
		    return results[1];
		}
 
        var assignmentId = gup('assignmentId');
    	var hitId = gup('hitId');
    	var workerId = gup('workerId');
 
        $(document).ready(function() 
    	{
    		$('input#answerSSSSSXGGGXQQ').val(workerId);
    		$('#question01').hide();
    		$('input#answerSSSSSXGGGXQQ').val(assignmentId);
    		$('#question02').hide();
    		$('input#answerSSSSSXGGGXQQ').val(hitId);
    		$('#question03').hide();
    	})
</script>
in the 'startpage.pstl' and in the 'endpage.pstl',
<script language="Javascript">
    			document.getElementById('assignmentId').value = gup('assignmentId');
    			document.getElementById('hitId').value = gup('hitId');
    			document.getElementById('workerId').value = gup('workerId');
 
    		</script>

But i am not getting the values in the database. I have added three questions (hidden) whose answers are hitId, assignmentId and workerId. The database does not populate with the values. Am I going wrong somewhere?


Thank you,
H.
Last Edit: 5 years 1 month ago by hrshdhgd.

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now