- Posts: 3
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Create survey questions from a database query
- geoffreyostrin
- Topic Author
- Offline
- New Member
Less
More
3 years 2 months ago #212148
by geoffreyostrin
Create survey questions from a database query was created by geoffreyostrin
The attached diagram (hopefully) displays what I would like. Say I have a database of pupil-teacher information from a school, two tables: one with pupil-class; the other class-teacher.The first question in the survey asks what class they are in and the pupil selects appropriately. Their answer is then fed into a prepared SQL statement that pulls out those teachers associated with the selected class. These are then fed into the survey software so that the list of appropriate responses for the second question can then be generated.
Question: Can this be done with LimeSurvey? If so, how can I test it?
Question: Can this be done with LimeSurvey? If so, how can I test it?
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12881
- Thank you received: 3965
3 years 2 months ago #212150
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Create survey questions from a database query
You may use an ajax call.
In a question of type "short text" you enter the call
This is a prototype of a call.
In your script "getTeacher.php" you do your queries and return the teachers.
Now the teachers are stored in this questions and you can use them in your survey.
This is possible.
But: What is the number of classes and the number of teachers?
There might be better, shorter ways to do this with built-in features.
So, please, provide a realistic scheme (number of classes, total number of teachers, number of teachers/class (average).
Joffm
In a question of type "short text" you enter the call
Code:
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ $.post('https://www.myServer.de/getTeacher.php' , { myclass:"{Q1Class}"},function(data) { $('#question{QID} input[type="text"]').val(data) }); }); </script>
This is a prototype of a call.
In your script "getTeacher.php" you do your queries and return the teachers.
Now the teachers are stored in this questions and you can use them in your survey.
This is possible.
But: What is the number of classes and the number of teachers?
There might be better, shorter ways to do this with built-in features.
So, please, provide a realistic scheme (number of classes, total number of teachers, number of teachers/class (average).
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- geoffreyostrin
- Topic Author
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
3 years 2 months ago #212151
by geoffreyostrin
Replied by geoffreyostrin on topic Create survey questions from a database query
Thanks for the reply.
> So, please, provide a realistic scheme (number of classes, total number of teachers, number of teachers/class (average).
There are about 50 classes, 150 teachers, with about 15 teachers per class.
> So, please, provide a realistic scheme (number of classes, total number of teachers, number of teachers/class (average).
There are about 50 classes, 150 teachers, with about 15 teachers per class.
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12881
- Thank you received: 3965
3 years 2 months ago #212152
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Create survey questions from a database query
Well, here you can do anything with Expression Script/Manager and Relevance.
Joffm
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: DenisChenu
The topic has been locked.
- geoffreyostrin
- Topic Author
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
3 years 2 months ago #212153
by geoffreyostrin
Replied by geoffreyostrin on topic Create survey questions from a database query
> Expression Script/Manager and Relevance
I assume these are all searchable in the documentation. What version/level of LimeSurvey allows me to test this?
I assume these are all searchable in the documentation. What version/level of LimeSurvey allows me to test this?
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12881
- Thank you received: 3965
3 years 2 months ago #212159
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Create survey questions from a database query
As you see on the download page, version 4.x. is steill declared as "unstable".
Therefore we always recommend to use version 3.x.
Therefore we always recommend to use version 3.x.
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.