Welcome, Guest
Username: Password: Remember me

TOPIC: Connect LimeSurvey with database (or any other form of text storage)

Re: Connect LimeSurvey with database (or any other form of text storage) 2 years 7 months ago #73375

That's great! I am completely new to LimeSurvey so I don't know what "custom variables" or the "token table" is. I suppose that "token table" is the table where the answers are stored but anyway I should check the manual for more ;-). Thanks for helping!
The administrator has disabled public write access.

Re: Connect LimeSurvey with database (or any other form of text storage) 2 years 7 months ago #73378

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5324
  • Thank you received: 294
  • Karma: 249
Answers data is stored at the lime_survey_12345 table which is created when you activate a survey.
The token table holds participant information and tokens which can be seen as one time passwords, see: docs.limesurvey.org/Tokens&structure=Eng...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: Connect LimeSurvey with database (or any other form of text storage) 2 years 7 months ago #73379

Oh I see! So the idea (according to the third approach) is to "over-use" the token table, in the sense that it will do something other than what it's supposed to. I.e. create custom variables in the token table and use them to pre-fill a portion of the answers in the survey, at the time that the survey is loaded. Is this so?
Btw I didn't find anything in the "Tokens" section regarding "custom variables". Should I look somewhere else in the manual?
The administrator has disabled public write access.

Re: Connect LimeSurvey with database (or any other form of text storage) 2 years 7 months ago #73382

  • holch
  • holch's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 2643
  • Thank you received: 313
  • Karma: 115
Well, actually the custom variables have been created exactly for that: to pass information that is already avaible to the questionnaire and work with it (you can use filters based on it, etc).

So if you have a spreadsheet with the contacts and additional information per respondent, that you wouldn't need to ask again (or that you would like them to confirm) you can include this into the token table and this data can then be connected directly to the data from the questionnaire.

In the manual they are called "user-defined attribute fields" and can be found here:
docs.limesurvey.org/Tokens&structure=Eng...ned_attribute_fields
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | Question Attributes | Workarounds

If you found this answer helpful and it saved you some time please consider a donation to the project to keep Limesurvey going!
The administrator has disabled public write access.

Re: Connect LimeSurvey with database (or any other form of text storage) 2 years 7 months ago #73383

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5324
  • Thank you received: 294
  • Karma: 249
At the token table you can store individual attribute data for each entry, see docs.limesurvey.org/Tokens&structure=Eng...ned_attribute_fields

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: Connect LimeSurvey with database (or any other form of text storage) 2 years 7 months ago #73406

  • Something
  • Something's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 4
  • Karma: 1
Hello!

Thank you for your answers!
Mazi wrote:
The problem with the approach you are describing is that Limesurvey stores all answer data at the lime_survey_12345 (12345 = survey ID) table with an incrementing ID. You can't partly fill that table and let the user add the rest.

This is not exactly what I meant :-)
What I meant was to create and use a new table (not lime_survey_12345) in the LimeSurvey DB, which I will populate (somehow) with the data required to pre-fill some fields of the questionnaire. Let's call it prefil_12345. Then, when LimeSurvey would load the questionnaire to show it to the user, it would also load certain fields from the prefil_12345 table. When the user completes the survey, it would be eventually stored in the lime_survey_12345 table (along with the prefiled values).
holch wrote:
Well, actually the custom variables have been created exactly for that: to pass information that is already avaible to the questionnaire and work with it (you can use filters based on it, etc).

So if you have a spreadsheet with the contacts and additional information per respondent, that you wouldn't need to ask again (or that you would like them to confirm) you can include this into the token table and this data can then be connected directly to the data from the questionnaire.

So this is great! It is exactly what I was thinking of, albeit the table is already there, and there is no need to create a new one in the DB :-)

Regarding populating the token table with external data, I could create a simple service that fetches the required data from an external file (e.g. txt or xml) or even another DB and put them in there, to be used then by LimeSurvey.
The administrator has disabled public write access.

Re: Connect LimeSurvey with database (or any other form of text storage) 2 years 7 months ago #73407

So you create these attribute fields (I suppose that you can create as many as you want), and then you use javascript to load them as pre-filled answers in certain survey questions, at loading time. Got it ;-)
And if I want to pre-fill an answer, but this time from the answers of another (answered) survey, rather than from the token table? Can I as well use javascript to load these answers from the lime_survey_12345 table?
The administrator has disabled public write access.

Re: Connect LimeSurvey with database (or any other form of text storage) 2 years 7 months ago #73408

  • Something
  • Something's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 4
  • Karma: 1
yannischris wrote:
So you create these attribute fields (I suppose that you can create as many as you want), and then you use javascript to load them as pre-filled answers in certain survey questions, at loading time. Got it ;-)
And if I want to pre-fill an answer, but this time from the answers of another (answered) survey, rather than from the token table? Can I as well use javascript to load these answers from the lime_survey_12345 table?
But why would you like to do this? You would have to choose one of the many answers to the same questionnaire to use as prefil values. Unless you only allow one user to fill the source questionnaire. Anyway, I guess it should be doable but in a less straightforward manner than just using the custom variables.
The administrator has disabled public write access.

Re: Connect LimeSurvey with database (or any other form of text storage) 2 years 7 months ago #73411

Yes that's what I had in mind! Imagine that there is a survey that is not user specific, from which I want to extract some pre-filled answers for the user specific ones.
The administrator has disabled public write access.

Re: Connect LimeSurvey with database (or any other form of text storage) 2 years 7 months ago #73418

  • holch
  • holch's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 2643
  • Thank you received: 313
  • Karma: 115
For the first part, I think you don't even have to do it via Javascript. I think "INSERTANS" works with the custom variables as well. But I am not 100% sure there.
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | Question Attributes | Workarounds

If you found this answer helpful and it saved you some time please consider a donation to the project to keep Limesurvey going!
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.148 seconds
Donation Image