Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Filter Multiple Choice answers based on option-specific quotas

  • kater_at
  • kater_at's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 2 weeks ago #181166 by kater_at
MC: Which Keynotes would you like to attend?

A) Speaker A
B) Speaker B
C) Speaker C

Each option/subquestion would need a specific quota (like 50 seats available) and become disabled / invisible after being fulfilled.

thank you!
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 2 weeks ago #181172 by DenisChenu
Not directly via LimeSurvey core : need a plugin or a Question template.

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.
  • Joffm
  • Joffm's Avatar
  • Online
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 2 weeks ago #181176 by Joffm
Hi,
unfortunately the quota management system of LS is a bit basic.
Inside the survey you have no access to values like:
quota_Target (in your case 50)
quota_Done (how many cases are already done in this quota)
quota_Todo (how many cases are still open in this quota).
This is something that could solve your problem.

But there is something you can do:
If you have some knowledge of php and SQL - and you have access to the LS database - you can use an ajax call.
Before this question create a question (let's say of type "short text" with code "QQuota")
In this question you enter:
Code:
<script type="text/javascript" charset="utf-8">
$(document).on('ready pjax:scriptcomplete',function(){
  $.post('https://www.domain.de/test/getQuota.php' , { sid: "{SID}", gid: "{GID}", qid:"[here enter the question ID of the keynote question]" },function(data) {
 
                   $('#question{QID} input[type="text"]').val(data)
 
      });
//  $('#question{QID}').hide();
  });
</script>

The php script "getQuota.php" now queries the database and - that's my idea - returns a string like "010" or "100", or
meaning:
1st character = 0 -> quota of Speaker A not full, =1 -> quota of Speaker A full
2nd character = 0 -> quota of Speaker B not full, =1 -> quota of Speaker B full
...


Now you can show or hide the "Speakers" by subquestion relevance like
"Speaker A" : substr(QQuota,0,1)=="0"

Best regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: kater_at
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Online
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 2 weeks ago #181191 by Joffm
Just to add something:
I returned the counts for the three speakers:

Now I click again speaker A:


Because there are only 10 places (in my example) now the option "Speaker A" is not displayed.


Regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: kater_at
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 2 weeks ago #181197 by DenisChenu
But better not using a javascript solutioin in my opinion :
gitlab.com/SondagesPro/getStatInSurvey is done for this …

You can put in the [Q01_speakerA.nb] to have the current people checked Y on Q01_speakerA etc …

See the example
Code:
{if(('[Q.nb.A1]'-100)>0,"There are "+('[Q.nb.A1]'-100)+" before this answer is quota out","This answer is quota out")}

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 following user(s) said Thank You: kater_at
The topic has been locked.
  • kater_at
  • kater_at's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 2 weeks ago #181227 by kater_at
Thanks for your great answers!

I'll test those.
The basic functionality - imho - is great with open source solutions. No feature creeping :)

cheers
The topic has been locked.
  • kater_at
  • kater_at's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 2 weeks ago #181241 by kater_at
Should the plugin work in 3.16 and EM ?
GIT: "You can not use this system in expression manager for answer part in LimeSurvey 3 and up."
thanks!
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Online
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 2 weeks ago #181246 by Joffm
Hi, Denis,

are you sure, this will work?

You can put in the [Q01_speakerA.nb] to have the current people checked Y on Q01_speakerA etc …


In the source code of the plugi there is no reference to question type "M"
Code:
                case 'nb':
                    switch ($oQuestion->type) {
                        case "5":
                        case "L":
                        case "!":
                        case "O":
                        case "I":
                        case "D":
                        case "N":
                        case "G":
                        case "Y":
                        case "*":
                        case "S":
                            return $this->getCount($this->iSurveyId."X".$oQuestion->gid."X".$oQuestion->qid, $sValue);
                        default:
                            return $this->_logUsage("{$sMatch} : Invalid question type : {$oQuestion->type} in {$this->sDebugWhere}");
                    }

I get the expected message: "Invalid question type..."

Kind regards
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.
  • kater_at
  • kater_at's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 2 weeks ago #181248 by kater_at
Until i can come up with a more comfortable way to enter quotas:
Code:
<script type="text/javascript" charset="utf-8">
$(document).on('ready pjax:scriptcomplete',function(){
// Option 1
  if (('[H.nb.H1]') >=0) { $('#javatbd871124X2X11H1').hide(); }
// Option 2
  if (('[H.nb.H2]') >=1) { $('#javatbd871124X2X11H2').hide(); }
// Option 3
  if (('[H.nb.H3]') >=2) { $('#javatbd871124X2X11H3').hide(); }
  });
</script>

thanks for your help!
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Online
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 2 weeks ago #181249 by Joffm
Hi, kater_at,

there is one question left:
What type is your "speaker"-question?

Because of your question "Which Keynotes would you like to attend?"
we, Denis and me, thought of a multipunch question.

But IMO your solution works - and it works fine - on a single punch question.
Was it thought as a single punch question?

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • kater_at
  • kater_at's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 2 weeks ago #181250 by kater_at
Hi Joffm,
Either.
A participant may choose multiple speakers or night-stays, ...
Picking a hotel only for a given night would allow for a single punch.

a extreme case would be:

Q1- Night 1
Q1__SQ001 -- Hotel A (Q: 50) (Checkbox)
Q1__SQ002 -- Hotel B (Q: 20) (Checkbox)
Q2- Night 2
Q2__SQ001 -- Hotel A (Q: 30) (Checkbox)
Q2__SQ002 -- Hotel B (Q: 50) (Checkbox)

I'm not done with "playing it through" yet but why wouldnt it work on multiple punch?
I would need to adapt this on ranking questions too.

thank you!
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 2 weeks ago #181263 by DenisChenu

Joffm wrote: Hi, Denis,

are you sure, this will work?

I get the expected message: "Invalid question type..."

Totally right … :( not implemented …

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