Saving to LS, but submitting to an external site

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

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

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

Please Log in to join the conversation.

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

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

Please Log in to join the conversation.

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

Please Log in to join the conversation.

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

hrshdhgd wrote: and it is in 'startpage.pstpl'

Think it's best to put it directly in group description.

First:
- remove all hide function
- With the real question number, test with:
$('#question13732 input.text').val(workerId);
$('#question13733 input.text').val(assignmentId);
$('#question13734 input.text').val(hitId);

If it don't work, test with:
$('#question13732 input.text').val("TEST");
$('#question13733 input.text').val("TESTassignmentId");
$('#question13734 input.text').val("TESThitId");

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 7 months ago #79743 by hrshdhgd
hrshdhgd replied the topic: Saving to LS, but submitting to an external site
I tried both codes. No difference noticed. I have attached a screenshot of my database. Nothing gets populated in the three fields for the IDs using both codes.
Thanks,
H.
Attachments:

Please Log in to join the conversation.

More
5 years 7 months ago #79781 by DenisChenu
DenisChenu replied the topic: Saving to LS, but submitting to an external site
There are some problem with your javascript then.

It's very difficult to help you without an access on the server.

You can see the real id for inout with Firebug for example.

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 7 months ago #79805 by hrshdhgd
hrshdhgd replied the topic: Saving to LS, but submitting to an external site
I have sent you a private message with the details to access the survey. Hope it helps,

Thanks,
H.

Please Log in to join the conversation.

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

You use "allways hide this question", don't use it: the answer aren't in DOM if this question is hidden like that.

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 7 months ago - 5 years 7 months ago #79816 by hrshdhgd
hrshdhgd replied the topic: Saving to LS, but submitting to an external site
Ok. So what should I do next?

I was asked to save the info (Ids) into a hidden question (if you refer the thread) and I thought thats how it should be done! Is there anything I am missing?

Thanks,
H.
Last Edit: 5 years 7 months ago by hrshdhgd.

Please Log in to join the conversation.

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

hrshdhgd wrote: Ok. So what should I do next?

Did it work ? If you show the answer, you see the answer filled ?

If yes, i think you can hide the question with relevance to 0. But you hide oit to in javascript with $("#question100").hide();
The question are hide in CSS not in HTML source, the javascript can access it.

I was asked to save the info (Ids) into a hidden question (if you refer the thread)

Saving to LS, but submitting to an external site ;) and there are more than one solution in the topic :).

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 7 months ago #79819 by hrshdhgd
hrshdhgd replied the topic: Saving to LS, but submitting to an external site

Did it work ? If you show the answer, you see the answer filled ?


Nope, unfortunately that did not work! I tried both:
$('input#answer78151X412X13732').val(workerId);
and
$('#question13732 input.text').val(workerId);

by making the questions visible, neither of them worked.


Any other suggestions?

Thanks,
H

Please Log in to join the conversation.

More
5 years 7 months ago - 5 years 7 months ago #79841 by DenisChenu
DenisChenu replied the topic: Saving to LS, but submitting to an external site
Hello,

Remove all script from startpage.pstpl or endpage.pstpl.

Put the script in template.js.
function getURLParameter(name) {
    return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null;
}
 
 
$(document).ready(function(){
  var assignmentId = getURLParameter('assignmentId');
  var hitId = getURLParameter('hitId');
  var workerId = getURLParameter('workerId');
 
  $('#question13732 input.text').val(workerId);
  $('#question13733 input.text').val(assignmentId);
  $('#question13734 input.text').val(hitId);	
});

tested and working for me.

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 .
Last Edit: 5 years 7 months ago by DenisChenu.

Please Log in to join the conversation.

More
5 years 7 months ago #79845 by hrshdhgd
hrshdhgd replied the topic: Saving to LS, but submitting to an external site

Remove all script from startpage.pstpl or endpage.pstpl.

Put the script in template.js.

function getURLParameter(name) {
    return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null;
}
 
 
$(document).ready(function(){
  var assignmentId = getURLParameter('assignmentId');
  var hitId = getURLParameter('hitId');
  var workerId = getURLParameter('workerId');
 
  $('#question13732 input.text').val(workerId);
  $('#question13733 input.text').val(assignmentId);
  $('#question13734 input.text').val(hitId);	
});

tested and working for me.

Denis

I did exactly as you instructed, deactivated and reactivated both Amazon Mechanical Turk and LimeSurvey. It still does not show as answers to the questions (which are visible) and the responses in the database is blank. I really appreciate all your patience and help so far but I still don't understand why is it not working for me.

Thanks,
H

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!