Check out the LimeSurvey source code on GitHub!

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

More
5 years 1 month ago #73075 by yannischris
Hello all,
I want to use LimeSurvey to create some simple questionnaires. However, there is a restriction: Some of the fields of the questionnaires should not be filled by the end users. Rather, they should be automatically filled in advance by text stored, e.g. in a database.
So, I was wondering whether I can use LimeSurvey in this way, i.e. to create a back-end interface with a database (or e.g. a simple text file) so as to pre-fill certain fields, leaving the rest of the fields to be filled by the end user (or edit the pre-filled ones).

So is that something like this possible?

Thanks,
Yannis

Please Log in to join the conversation.

More
5 years 1 month ago - 5 years 1 month ago #73116 by Steve01
Hello,

what LimeSurvey version do you use?

If you want to prefill answers you can use the SGQA-Code in the URL. So it might be a soluttion to create a php page/script that fetches the answers you want to prefill and create an URL that uses SGQA to prefill that questions.

EDIT:
Here is the "workaround" that describes how to do it:
docs.limesurvey.org/tiki-index.php?page=...ling_survey_elements

Mit freundlichen Grüßen/Best regards,

Stefan Gohlke
LimeSurvey Team
Last Edit: 5 years 1 month ago by Steve01.
The following user(s) said Thank You: yannischris

Please Log in to join the conversation.

More
5 years 1 month ago - 5 years 1 month ago #73117 by yannischris
Hello and thanks for the useful reply!
I haven't used LimeSurvey yet, but of course I'm planning to. So which version should I use in order to have this feature?

The SGQA Identifier seems really the thing that will do the job! However, in the link you provided I read only about prefilling answers via Query URL. But can I pre-load answers from a database? Is this described somewhere in the manual?

Thanks!
Last Edit: 5 years 1 month ago by yannischris.

Please Log in to join the conversation.

More
5 years 1 month ago #73125 by Mazi
The current stable version is 1.91.

If you want to prefill answers by URL, you of course have to manipulate the survey entry link to populate the URL with data from your DB.

Another approach would be to place an Ajax call at certain survey questions and query the DB at runtime. There are some Ajax examples at the forum but they are quite complicated to set up.
You probably also need some kind if ID within the survey and at the DB to query the correct data sets.


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

More
5 years 1 month ago #73134 by Something
Hi! I was also looking at doing something similar.

My understanding is that LimeSurvey uses a MySQL database for storing questionnaires, answers, etc.

I imagine that you could create some extra tables in that database and populate them with the data that you need to be pre-filled. Then, you could load that data directly from the LimeSurvey DB into the corresponding questionnaire fields.

I guess that you could also create an external application that fetches data from some other external database(s) into the new LimeSurvey DB tables that you have created for your purposes, if you wish so.

Do you think that this may be feasible?

Cheers

Please Log in to join the conversation.

More
5 years 4 weeks ago #73221 by Mazi
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.
So one alternative approach might be to use an Ajax call to an external DB and then use Javascript to populate some fields/radio boxes/check boxes at a survey page.
The second approach is to manipulate the link to the survey and pass data into the survey by URL to pre-populate fields. One example can be found here: docs.limesurvey.org/Workarounds%3A+Surve...ling_survey_elements


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

More
5 years 4 weeks ago #73268 by yannischris
Ok it's good that there are a couple of ways to work this thing around!

The problem with the URL approach could be that in my case the questionnaires will have a lot of questions and in some cases a large portion of these questions need to be pre-filled. So maybe the adding all those data to the url could be an issue.

The Ajax approach looks more likely to tackle my requirement. Has anybody implemented this approach?
Are there any tutorials/examples/documentation that I can refer to in order to get some help?

Please Log in to join the conversation.

More
5 years 4 weeks ago #73273 by Mazi
To my knowledge, URLs are limited to 2048 characters, so that might indeed cause problems when passing lots of data.

There are some Ajax examples at the forum and I think at manual -> workarounds as well but I'm not sure if they deal with a similar problem.
I once implemented something related for a customer who was displaying tables with data for different products. Those details were loaded by an Ajax call and populated at a survey question.
In your case it might be useful to implement one Ajax call for each survey page.


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

More
5 years 4 weeks ago #73290 by holch
If you want to preload them anyway, why not use the "custom variables" for the token table? You can access those variables from within your questionnaire, prefill questions with it or write them in the question text.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in to join the conversation.

More
5 years 4 weeks ago #73307 by Mazi

holch wrote: If you want to preload them anyway, why not use the "custom variables" for the token table? You can access those variables from within your questionnaire, prefill questions with it or write them in the question text.

That might also work, but the survey has to be NON anonymous in this case.


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

More
5 years 3 weeks ago #73375 by yannischris
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!

Please Log in to join the conversation.

More
5 years 3 weeks ago #73378 by Mazi
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)survey-consulting.com'"

Please Log in to join the conversation.

More
5 years 3 weeks ago #73379 by yannischris
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?

Please Log in to join the conversation.

More
5 years 3 weeks ago #73382 by holch
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

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in to join the conversation.

More
5 years 3 weeks ago #73383 by Mazi
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)survey-consulting.com'"

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form