- Posts: 59
- Thank you received: 9
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Saving respondent's paradata
- eloner
- Topic Author
- Offline
- Senior Member
Less
More
9 years 1 month ago #116809
by eloner
Saving respondent's paradata was created by eloner
Hello!
I am using LS since 2012 and it is working fine for my purposes!
I need to save some paradata about the respondent's device (cookies enabled, browser name, engine) in the answers file.
To do this I created a question (Q10, type: equation):
I added the following code to the question:
<p id="device">
</p>
<script>
document.getElementById("device").innerHTML =
"Cookies Enabled is: " + navigator.cookieEnabled
+ "; Browser name is: " + navigator.appName
+ "; Browser code name is: " + navigator.appCodeName
+ "; Engine: " + navigator.product
</script>
In the preview I can see the data I am requesting:
My problem is that the data should be stored in the answers, but it doesn't work.
(I also need to hide the question, but this is the second step of my problem).
What is wrong in my text? Maybe something in the code (I am not expert of Javascript !)?
I am using LS Version 2.05+ Build 141229.
Any suggestion would be appreciated!!!!
Thanks
elo
I am using LS since 2012 and it is working fine for my purposes!
I need to save some paradata about the respondent's device (cookies enabled, browser name, engine) in the answers file.
To do this I created a question (Q10, type: equation):
I added the following code to the question:
<p id="device">
</p>
<script>
document.getElementById("device").innerHTML =
"Cookies Enabled is: " + navigator.cookieEnabled
+ "; Browser name is: " + navigator.appName
+ "; Browser code name is: " + navigator.appCodeName
+ "; Engine: " + navigator.product
</script>
In the preview I can see the data I am requesting:
My problem is that the data should be stored in the answers, but it doesn't work.
(I also need to hide the question, but this is the second step of my problem).
What is wrong in my text? Maybe something in the code (I am not expert of Javascript !)?
I am using LS Version 2.05+ Build 141229.
Any suggestion would be appreciated!!!!
Thanks
elo
Attachments:
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10634
- Thank you received: 3698
9 years 1 month ago #116817
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 Saving respondent's paradata
Place the following script into a short-text question. It will hide that question and load your data.
Or better, this in the source of a multiple-short-text with 3 sub-questions:
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify this question var thisQuestion = $('#question{QID}'); // Hide this question thisQuestion.hide(); // Load the text input $('input.text', thisQuestion).val("Cookies Enabled is: " + navigator.cookieEnabled + "; Browser name is: " + navigator.appName + "; Browser code name is: " + navigator.appCodeName + "; Engine: " + navigator.product); }); </script>
Or better, this in the source of a multiple-short-text with 3 sub-questions:
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify this question var thisQuestion = $('#question{QID}'); // Hide this question thisQuestion.hide(); // Load the text input $('input.text:eq(0)', thisQuestion).val(navigator.cookieEnabled); $('input.text:eq(1)', thisQuestion).val(navigator.appName); $('input.text:eq(2)', thisQuestion).val(navigator.product); }); </script>
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: eloner
The topic has been locked.
- eloner
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 59
- Thank you received: 9
9 years 1 month ago #116823
by eloner
Replied by eloner on topic Saving respondent's paradata
Wow!!!!
It works perfectly!
Thank you Tony for your precious help!!!!
Elo
It works perfectly!
Thank you Tony for your precious help!!!!
Elo
The topic has been locked.
- gremlin
- Offline
- New Member
Less
More
- Posts: 10
- Thank you received: 0
5 years 4 months ago #177341
by gremlin
Replied by gremlin on topic Saving respondent's paradata
Hi Tony,
This does not work in the latest version any more. Do the scripts need some updating? Thanks!!!
Gre
This does not work in the latest version any more. Do the scripts need some updating? Thanks!!!
Gre
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10634
- Thank you received: 3698
5 years 4 months ago #177344
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 Saving respondent's paradata
Try this:
Code:
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ // Identify this question var thisQuestion = $('#question{QID}'); // Hide this question thisQuestion.hide(); // Load the text input $('input:text:eq(0)', thisQuestion).val(navigator.cookieEnabled); $('input:text:eq(1)', thisQuestion).val(navigator.appName); $('input:text:eq(2)', thisQuestion).val(navigator.product); }); </script>
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: gremlin
The topic has been locked.
- gremlin
- Offline
- New Member
Less
More
- Posts: 10
- Thank you received: 0
5 years 4 months ago #177345
by gremlin
Replied by gremlin on topic Saving respondent's paradata
Still doesn't seem to work. The fields are returning blanks on the view responses page.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13935
- Thank you received: 2551
5 years 4 months ago #177349
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 Saving respondent's paradata
For browser name an version :
gitlab.com/SondagesPro/QuestionSettingsType/findUserAgentInfo
Unsure it still work on 3.0 but can be tested
Unsure it still work on 3.0 but can be tested
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.
The following user(s) said Thank You: gremlin
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11758
- Thank you received: 2753
5 years 4 months ago #177367
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Saving respondent's paradata
Is your survey set up to use Javascript?
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The following user(s) said Thank You: gremlin
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10634
- Thank you received: 3698
5 years 4 months ago #177381
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 Saving respondent's paradata
It works for me. Can you activate a test survey and give a link here?Still doesn't seem to work. The fields are returning blanks on the view responses page.
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: gremlin
The topic has been locked.
- gremlin
- Offline
- New Member
Less
More
- Posts: 10
- Thank you received: 0
5 years 4 months ago #177383
by gremlin
Replied by gremlin on topic Saving respondent's paradata
Sorry guys! Yes the new script works! I wasn't sure why it didn't at first but after replacing the entire script it worked! I had initially only replaced the 'ready pjax:scriptcomplete' portion. Thanks everyone!
The topic has been locked.
- bedendo
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
3 years 10 months ago #200228
by bedendo
Replied by bedendo on topic Saving respondent's paradata
Hi guys, I followed your steps but data is not being saved. What am I missing?
Here's what I did:
1)added new multiple short text question named device
2)pasted the following code in Source
<script type="text/javascript" charset="utf-8">
$(document).on('ready pjax:scriptcomplete',function(){
// Identify this question
var thisQuestion = $('#question{QID}');
// Hide this question
thisQuestion.hide();
// Load the text input
$('input:text:eq(0)', thisQuestion).val(navigator.cookieEnabled);
$('input:text:eq(1)', thisQuestion).val(navigator.appName);
$('input:text:eq(2)', thisQuestion).val(navigator.product);
});
</script>
3) saved the question
Here's a screenshot
Here's what I did:
1)added new multiple short text question named device
2)pasted the following code in Source
<script type="text/javascript" charset="utf-8">
$(document).on('ready pjax:scriptcomplete',function(){
// Identify this question
var thisQuestion = $('#question{QID}');
// Hide this question
thisQuestion.hide();
// Load the text input
$('input:text:eq(0)', thisQuestion).val(navigator.cookieEnabled);
$('input:text:eq(1)', thisQuestion).val(navigator.appName);
$('input:text:eq(2)', thisQuestion).val(navigator.product);
});
</script>
3) saved the question
Here's a screenshot
The topic has been locked.
- eloner
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 59
- Thank you received: 9
3 years 10 months ago #200229
by eloner
Replied by eloner on topic Saving respondent's paradata
Dear bedendo,
to answer we should know which version you are using.
However, on the latest release (3.2x) I found useful this solution:
forums.limesurvey.org/forum/design-issue...ed-via-mobile-device
Best,
Enzo
to answer we should know which version you are using.
However, on the latest release (3.2x) I found useful this solution:
forums.limesurvey.org/forum/design-issue...ed-via-mobile-device
Best,
Enzo
The following user(s) said Thank You: bedendo
The topic has been locked.