Welcome to the LimeSurvey Community Forum

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

Prefill questions/answers with external Data

  • rajkumar_dms
  • rajkumar_dms's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
3 days 9 hours ago #268336 by rajkumar_dms
Prefill questions/answers with external Data was created by rajkumar_dms
Please help us help you and fill where relevant:
LimeSurvey version: [6.8]
Own server or LimeSurvey Cloud:Cloud
Survey theme/template:
==================
Hello Team,

You are doing well

I had some external data i would like import these data in the server and then retrieved that data from data file and show in the survey on basis of id

Is it possible to do that

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 days 3 hours ago #268340 by holch
Common, Raj, you are here for a while now. This is answered at least on a weekly basis. A quick search in the forum should bring up several posts with solutions.

But anyway, here a few hints how you could approach this:

1. Given that you say you want to upload this data to the server, I think your best bet is a token based (closed) survey. Limesurvey gives you the possibility to create custom attributes in the token/participant table, besides the standard ones (like name, email, etc). So you can create specific custom attributes and then upload the data via CSV into the token table.

Then you can referrence the data from these custom attribute fields from within the survey, by using something like {TOKEN:ATTRIBUTE_1} for example.

Some more information here (ignore the part of INSERTANS, it might still work, but I wouldn't use it anymore, in your case it is also competely irrelevant, you should look at the TOKEN part).

Also have a look here about survey participants:
www.limesurvey.org/manual/Survey_participants

And specifically here:
www.limesurvey.org/manual/Survey_participants#Manage_attributes

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Please Log in to join the conversation.

  • rajkumar_dms
  • rajkumar_dms's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
3 days 3 hours ago #268343 by rajkumar_dms
Replied by rajkumar_dms on topic Prefill questions/answers with external Data
Thanks for your response

It's i open accessed mode survey with some specific data like Name ,Gender,Age like etc will retrive from external file and show in the data table

is it possible with lime survey

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 days 3 hours ago #268344 by holch
Well, if it is an open access mode survey, how will you connect name, gender, age, etc. with the respective respondent?

You will need to give us a little bit more information here.

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: DenisChenu

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 days 1 hour ago - 3 days 1 hour ago #268346 by Joffm

I had some external data i would like import these data in the server and then retrieved that data from data file and show in the survey on basis of id

My first question is answered now. Open or closed: Closed.

Now to your "external data". What kind?
Flat file? csv, json, ...,  or what?
Database?

"Based on id". Which id? Does the respondent enter an id? Or what do you imagine?

As @holch: Please, more information.

Joffm

In the meantime you may read this and study this library
[url] forums.limesurvey.org/forum/can-i-do-thi...insert-text-from-csv [/url]

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 3 days 1 hour ago by Joffm.

Please Log in to join the conversation.

  • rajkumar_dms
  • rajkumar_dms's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
2 days 10 hours ago #268347 by rajkumar_dms
Replied by rajkumar_dms on topic Prefill questions/answers with external Data
It's a opened survey and external data is csv file format and in that file a unique id present in it, when respondent enter that unique in the survey then that id related answer will be pre filled in the respectively ,data may be pre filed into Multiple short text question or may any individual type question

Please Log in to join the conversation.

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
2 days 7 hours ago #268352 by DenisChenu
Replied by DenisChenu on topic Prefill questions/answers with external Data
Solution : Replace token by ID and use TOKEN:ATTRIBUTE_X for default value.

BUT : if with only one ID you can get all user information : i hope this ID are really complex !! More than 15 characters, not only numeric.

We really need more information here !

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 days 6 hours ago #268353 by Joffm
Hi,
you are always a bit vague.

As I couild imagine a scenario to do this:
  • The respondent enters an id.
  • There may be some matching data in the csv file or not.
  • If there are data you display them and the respondent may change them (e.g. if he changed his address)
  • If not you display empty fields.
This you can do with the library "Papaparse" that I showed already.
With a file like this
 
you get
 

or
 
 

And now you can preset each question type by an equation with the these results.
Code:
</script><script type="text/javascript" charset="utf-8">
  $(document).on('ready pjax:complete',function() {
 
       var id = '{Q1}';
 
      Papa.parse("/lime6/upload/surveys/{SID}/files/test1.csv", {
          download: true,
          header: true,
          skipEmptyLines: true,
          complete: function(results) {
              for (i=0; i < results.data.length; i++) {
                  if (results.data[i].id==id) {
                      $('#question{QID} input[type="text"]:eq(0)').val(results.data[i].firstname);
                      $('#question{QID} input[type="text"]:eq(1)').val(results.data[i].lastname);
                      $('#question{QID} input[type="text"]:eq(2)').val(results.data[i].gender);
                      $('#question{QID} input[type="text"]:eq(3)').val(results.data[i].age);
                      break;
                  }
              }
          }
      });
  });
</script>

Or do ALL respondents have matching data in the file?
In this case you ought to run a closed survey with the Id as token and the data as additional attributes.
Which is much more straightforwaed.


 

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

  • rajkumar_dms
  • rajkumar_dms's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
2 days 3 hours ago #268361 by rajkumar_dms
Replied by rajkumar_dms on topic Prefill questions/answers with external Data
Hi,

I had tried the same seems i may missed some step so that i can get the result please can you on it

Also attached the lss and csv file for the same

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 days 1 hour ago - 2 days 58 minutes ago #268368 by Joffm
Hi,
you didn't follow the instructions in the shown link.
There you saw
 
But in your lss you did not load the library.

Second: I would avoid apostrophs, just "RespondentName"

 

Joffm

I saw that your file is ANSI coded, but the script is utf-8. You should adapt this.

 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 2 days 58 minutes ago by Joffm.

Please Log in to join the conversation.

  • rajkumar_dms
  • rajkumar_dms's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
1 day 10 hours ago #268382 by rajkumar_dms
Replied by rajkumar_dms on topic Prefill questions/answers with external Data
Thanks Joffm for your guidance

it's strange behaviours I had follow your step but i could not succussed for pulling data either i may missed somethings so that i can not retrieve the data

I am using lime survey could version 

Again i attached the same please look into this

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 day 5 hours ago #268386 by Joffm
Question:
"/lime6/upload/surveys/629548/files/test2.csv"
Is this your correct path?
I really doubt.

An easy way to find out your path is to use the wizard to insert an image.
Then you will see something like this in your question text
Code:
<img alt="" src="/lime6/upload/surveys/629548/images/Boot001_klein.jpg" />
And you see your path to the image; if you uploaded to "files", you have to change this.

Joffm

 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: rajkumar_dms

Please Log in to join the conversation.

Moderators: holchtpartner

Lime-years ahead

Online-surveys for every purse and purpose