Welcome, Guest
Username: Password: Remember me

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

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

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
The administrator has disabled public write access.

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

  • Steve
  • Steve's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 494
  • Thank you received: 46
  • Karma: 17
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: 2 years 7 months ago by Steve.
The administrator has disabled public write access.
The following user(s) said Thank You: yannischris

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

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: 2 years 7 months ago by yannischris.
The administrator has disabled public write access.

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

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5324
  • Thank you received: 294
  • Karma: 249
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)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 #73134

  • Something
  • Something's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 4
  • Karma: 1
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
The administrator has disabled public write access.

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

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5324
  • Thank you received: 294
  • Karma: 249
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)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 #73268

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?
The administrator has disabled public write access.

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

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5324
  • Thank you received: 294
  • Karma: 249
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)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 #73290

  • holch
  • holch's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 2640
  • Thank you received: 313
  • Karma: 115
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.
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 #73307

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5324
  • Thank you received: 294
  • Karma: 249
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)limesurvey.org'"
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.137 seconds
Donation Image