- Posts: 38
- Thank you received: 1
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Count the number of completed answers according to the answer to a question
- zserban
- Topic Author
- Offline
- Junior Member
Less
More
3 years 4 months ago #209347
by zserban
Count the number of completed answers according to the answer to a question was created by zserban
Hello,
Suppose you want to show a list of choices on a question (Q1), depending on how many respondents have already picked certain choices of Q1.
Q1. Question type list
Answers:
1 .....
2 ....
3 ...
4 ...
5 ...
If 5 respondents already picked 1, then only display 2 to 5.
I was thinking that Q1 can be filtered by using a equation question plus a multiple question, but i am not sure what kind of logic i can use on the equation question to count the responses at survey level.
Thank you,
Serban
Suppose you want to show a list of choices on a question (Q1), depending on how many respondents have already picked certain choices of Q1.
Q1. Question type list
Answers:
1 .....
2 ....
3 ...
4 ...
5 ...
If 5 respondents already picked 1, then only display 2 to 5.
I was thinking that Q1 can be filtered by using a equation question plus a multiple question, but i am not sure what kind of logic i can use on the equation question to count the responses at survey level.
Thank you,
Serban
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12881
- Thank you received: 3965
3 years 4 months ago #209351
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Count the number of completed answers according to the answer to a question
Hi, Serban,
You can use an ajax call to query the database, or you may try to use the plugin
gitlab.com/SondagesPro/ExportAndStats/getStatInSurvey
with some additional javascript.
Here an example with the plugin.
In a group before your single question put a question of type "multiple short text" (QValues) with this javascript.
(Q1 is the single question you want to count)
Here you store the values into the multiple short text.
Now the usual part to be able to use an array filter.
Before your question
put a question of type "equation" (eqHM) where you check the following question of type "multiple" (HM) if the value is still less than 5.
{HM_1=if(QValues_SQ001<5,"Y","")}
{HM_2=if(QValues_SQ002<5,"Y","")}
{HM_3=if(QValues_SQ003<5,"Y","")}
{HM_4=if(QValues_SQ004<5,"Y","")}
Now you set the array filter of your question on HM.
Have a look at the example.
Joffm
There is no.what kind of logic i can use on the equation question to count the responses at survey level.
You can use an ajax call to query the database, or you may try to use the plugin
gitlab.com/SondagesPro/ExportAndStats/getStatInSurvey
with some additional javascript.
Here an example with the plugin.
In a group before your single question put a question of type "multiple short text" (QValues) with this javascript.
(Q1 is the single question you want to count)
Code:
<script> $(document).on('ready pjax:scriptcomplete',function(){ // Identify this question var thisQuestion = $('#question{QID}'); // Fill the fields, one line for each option $('input[type=text]:eq(0)', thisQuestion).val( {'[Q1.nb.1]'} ); $('input[type=text]:eq(1)', thisQuestion).val( {'[Q1.nb.2]'} ); $('input[type=text]:eq(2)', thisQuestion).val( {'[Q1.nb.3]'} ); $('input[type=text]:eq(3)', thisQuestion).val( {'[Q1.nb.4]'} ); // Hide the question $('#question{QID}').hide(); }); </script>
Here you store the values into the multiple short text.
Now the usual part to be able to use an array filter.
Before your question
put a question of type "equation" (eqHM) where you check the following question of type "multiple" (HM) if the value is still less than 5.
{HM_1=if(QValues_SQ001<5,"Y","")}
{HM_2=if(QValues_SQ002<5,"Y","")}
{HM_3=if(QValues_SQ003<5,"Y","")}
{HM_4=if(QValues_SQ004<5,"Y","")}
Now you set the array filter of your question on HM.
Have a look at the example.
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.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13597
- Thank you received: 2487
3 years 4 months ago #209371
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Count the number of completed answers according to the answer to a question
Hi,
LimeSurvey version please ?
LimeSurvey version please ?
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.