Welcome, Guest
Username: Password: Remember me

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

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

  • hrshdhgd
  • hrshdhgd's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 29
  • Karma: 0
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: 2 years 4 months ago by hrshdhgd.
The administrator has disabled public write access.

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

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5324
  • Thank you received: 294
  • Karma: 248
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)limesurvey.org'"
The administrator has disabled public write access.

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

  • hrshdhgd
  • hrshdhgd's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 29
  • Karma: 0
Sounds like a great plan!! How do I go about doing that?
The administrator has disabled public write access.

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

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5324
  • Thank you received: 294
  • Karma: 248
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)limesurvey.org'"
The administrator has disabled public write access.

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

  • hrshdhgd
  • hrshdhgd's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 29
  • Karma: 0
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: 2 years 3 months ago by hrshdhgd.
The administrator has disabled public write access.

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

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6268
  • Thank you received: 800
  • Karma: 239
hrshdhgd wrote:
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?
Hello,

The 3 question aren't in start page, with JS you work on the DOM of the actual window, then you need the 3 question in the first page.

Maybe you can put the 3 question in a first group.

Use the first group description for the welcome part. And set "Show welcome screen?" to NO.


The alternative solution are to use SGQA directly in the first URL
See: Prefilling survey answers using the survey URL

Denis
The administrator has disabled public write access.

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

  • hrshdhgd
  • hrshdhgd's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 29
  • Karma: 0
Hey Denis,
Thanks for your prompt response.

I already have the 3 questions in the first group and yet the above mentioned code did not work. The first group consists of 3 questions namely: hitId, assignmentId and workerId with answer type = 'long free text' each. The 'description' in the first group is empty (do I need to put anything there?), so I do not understand what do I have to put in the 'Welcome page' description as suggested by you. I had already turned "Show welcome screen?" to NO in the beginning itself.

The alternative solution of using SGQA does not seem fit to the situation (I may be wrong here). The url I need to get information from looks like this:

"workersandbox.mturk.com/mturk/accept?hit...=xxxxxxxx........and so on"

According to my understanding the SGQA doc solution will work for the end URL when I need to pass this information to my web application from LS. I have to first get this information into the LS database from the mturk link I have mentioned above for which I am using the first group (3 questions). I apologize for being so naive but I am new to all this. I really appreciate your patience.

Thanks,
H.
The administrator has disabled public write access.

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

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6268
  • Thank you received: 800
  • Karma: 239
For javascript solution, did you set "Show welcome screen?" to NO ?
If yes, can you give us a testing link ?
And maybe use another script for url parameter:
jquery-howto.blogspot.fr/2009/09/get-url...ues-with-jquery.html
stackoverflow.com/questions/1403888/get-...arameter-with-jquery


For Prefilling survey answers using the survey URL, you can't put what you want in the link ?
You can't put:
yoururl/index.php?SGQA1=assignmentId&SGQA2=hitId ???
The administrator has disabled public write access.

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

  • hrshdhgd
  • hrshdhgd's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 29
  • Karma: 0
Yes I did set "Show welcome screen?" to NO for the javascript solution. I am extremely sorry but LS is installed on our secure servers and unfortunately the administrator has denied me to grant you permission to access LS. I am helpless here.

I used another script for url parameter (stackoverflow.com) and at the end of it added:
alert(hitId);

So it gave me a dialogue with the hitId displayed which suggests that the code works! but apparently the following code responsible for putting the information into the answer field of the questions is not doing its job:
                $('input#answer78150X412X13732').val(workerId);
    		$('#question01').hide();
    		$('input#answer78150X412X13733').val(assignmentId);
    		$('#question02').hide();
    		$('input#answer78150X412X13734').val(hitId);
                $('#question02').hide();

where 78150 is the survey ID, 412 is the Group ID and 13734 is the Question ID. Is there something wrong here? I double checked the IDs and they are correct. I got this code from the LS website.

For the Prefilling survey answers solution, the url is automatically generated by the mturk application, I cannot modify the link.

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

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

  • hrshdhgd
  • hrshdhgd's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 29
  • Karma: 0
So the entire code looks like this:
 
 
	function getURLParameter(name)
	 {
    		return decodeURIComponent
    		(
        		(location.search.match(RegExp("[?|&]"+name+'=(.+?)(&|$)'))||[,null])[1]
    		);  
	}
 
	var assignmentId = getURLParameter('assignmentId');
    	var hitId = getURLParameter('hitId');
    	var workerId = getURLParameter('workerId');
 
    		$('input#answer78150X412X13732').val(workerId);
    		$('#question01').hide();
    		$('input#answer78150X412X13733').val(assignmentId);
    		$('#question02').hide();
    		$('input#answer78150X412X13734').val(hitId);
                $('#question03').hide();
    		alert(hitId);

and it is in 'startpage.pstpl'

Thanks,
H.
Last Edit: 2 years 3 months ago by hrshdhgd.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 1.363 seconds
Donation Image