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
  • zserban's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 4 months ago #209347 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
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 4 months ago #209351 by Joffm
Hi, Serban,

what kind of logic i can use on the equation question to count the responses at survey level.

There is no.
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.

File Attachment:

File Name: limesurvey...7555.lss
File Size:26 KB


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
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 4 months ago #209371 by DenisChenu
Hi,

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.

Lime-years ahead

Online-surveys for every purse and purpose