Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Saving respondent's paradata

  • eloner
  • eloner's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
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):

File Attachment:

File Name: limesurvey...2524.lsq
File Size:2 KB



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
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 1 month ago #116817 by tpartner
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.
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
  • eloner's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
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
The topic has been locked.
More
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
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 4 months ago #177344 by tpartner
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.
More
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
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 4 months ago #177349 by DenisChenu
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

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
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 4 months ago #177367 by holch
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
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 4 months ago #177381 by tpartner
Replied by tpartner on topic Saving respondent's paradata

Still doesn't seem to work. The fields are returning blanks on the view responses page.

It works for me. Can you activate a test survey and give a link here?

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.
More
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.
More
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
The topic has been locked.
  • eloner
  • eloner's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
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
The following user(s) said Thank You: bedendo
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose