Welcome to the LimeSurvey Community Forum

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

Ranking question filtering

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 4 months ago - 7 years 4 months ago #144383 by Joffm
Replied by Joffm on topic Ranking question filtering
Hi, all,
it is in the "ranking.css", not in the templates.
There is.
Code:
:dir(ltr) .dragDropTable .columns2{float:right}
.dragDropTable .clear{clear:both}
instead of "rtl".

So please create a bug report.

Best regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 7 years 4 months ago by Joffm. Reason: Typo
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 4 months ago #144595 by DenisChenu
Replied by DenisChenu on topic Ranking question filtering

Joffm wrote: So please create a bug report.

No, please ...

Update to last version, fixed since 2.53+161004 release.

github.com/LimeSurvey/LimeSurvey/commit/...363affb09738428a4021

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.
  • bcjewel
  • bcjewel's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 3 months ago #192381 by bcjewel
Replied by bcjewel on topic Ranking question filtering
Hi Tony - 3 years later, and we have a repeat of the same event happening, so I am using the same code that I used in 2016, but with a new version of Lime Survey - I'm now using 3.17.9+... and this code is not working. I've set "Filter HTML for XSS" to "Off" and used the exact same survey that I used in 2016, but none of the rank options show in this version. Any suggestions on how to make it work?

This is a sample of the code I'm using, this is for question "arHidden", then the following question (Active Rec) is a ranking question with an array filter of arHidden:
Code:
A hidden question to control the ranking. <script type="text/javascript" charset="utf-8">  
  $(document).ready(function() {
 
    // Identify the questions
    var arHidden = $('#question{QID}');
    var arHiddenID = $(arHidden).attr('id').replace(/question/, '');
 
    // Hide the checkbox question
    arHidden.css({
      'position': 'absolute',
      'left': '-9999em'
    });
 
    // The ranking answer codes relevant for the various values of "Branch"
    // EDIT HERE AS REQUIRED
    var answerCodes = {
      1: ['101', '102', '103', '104', '105', '106', '107', '108', '109', '110', '111', '112', '113', '114', '115'], // Seen by "Rangers"
      2: ['101', '102', '103', '104', '105', '106', '107', '108', '109', '110', '111', '112', '113', '114', '115'], // Seen by "Pathfinders"
      3: ['101', '103', '104', '105', '106', '108', '109', '110', '112', '114', '115'] // Seen by everybody else
    }
 
    // Get the value of the "Branch" question
    var branch = '{Branch}';
    console.log(branch);
 
    // Define which set of ranking answer codes to display
    if(branch == 'Ranger') {
      var codeArray = answerCodes[1];
    }
    else if(branch == 'Pathfinder') {
      var codeArray = answerCodes[2];
    }
    else {
      var codeArray = answerCodes[3];
    }
 
    // Toggle the appropriate checkboxes and fire Expression Manager
    $('input.checkbox[id$="X'+arHiddenID+this+'"]').prop('checked', false);
    $('.question-item input:hidden', arHidden).val('');
    $(codeArray).each(function(i) {
      var thisInput = $('input.checkbox[id$="X'+arHiddenID+this+'"]');
      thisInput.prop('checked', true);
      thisInput.nextAll('input:hidden').val('Y');
      checkconditions(thisInput.value, thisInput.name, thisInput.type)
    });
    });
</script>
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 3 months ago #192383 by tpartner
Replied by tpartner on topic Ranking question filtering
In 3.x versions, you will need to deactivate AJAX in the survey theme options and use this code:

Code:
<script type="text/javascript" charset="utf-8">  
  $(document).on('ready pjax:scriptcomplete',function(){
 
    // Identify the questions
    var qHidden = $('#question{QID}');
    var qHiddenID = $(qHidden).attr('id').replace(/question/, '');
 
    // Hide the checkbox question
    qHidden.css({
        'position': 'absolute',
        'left': '-9999em'
    });
 
    // The ranking answer codes relevant for the various values of "Branch"
    // EDIT HERE AS REQUIRED
    var answerCodes = {
      1: ['101', '102', '103', '104'], // Seen by "Rangers"
      2: ['101', '102', '103', '104', '105', '106'], // Seen by "Pathfinders"
      3: ['101', '102', '103', '104', '105', '106', '107', '108'] // Seen by everybody else
    }
 
    // Get the value of the "Branch" question
    var branch = '{Branch}';
 
    // Define which set of ranking answer codes to display
    if(branch == 'Ranger') {
      var codeArray = answerCodes[1];
    }
    else if(branch == 'Pathfinder') {
      var codeArray = answerCodes[2];
    }
    else {
      var codeArray = answerCodes[3];
    }
 
    // Toggle the appropriate checkboxes and fire Expression Manager
    $('.question-item input:hidden', qHidden).val('');
    $('input:checkbox[id$="X'+qHiddenID+this+'"]').prop('checked', false).trigger('change');
    $(codeArray).each(function(i) {
      var thisInput = $('input:checkbox[id$="X'+qHiddenID+this+'"]');
      thisInput.nextAll('input:hidden').val('Y');
      thisInput.prop('checked', true).trigger('change');
    });
    });
</script>

Sample survey attached:

File Attachment:

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

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • bcjewel
  • bcjewel's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 3 months ago #192386 by bcjewel
Replied by bcjewel on topic Ranking question filtering
Thank you! I'm back in business! I truly appreciate your prompt response.

Julie
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 3 months ago #192387 by Joffm
Replied by Joffm on topic Ranking question filtering
Hi,
let me join the conversation.

Is there a special reason to use javascript, and not an equation to set the relevant items in the hidden multiple question?

Like this:

File Attachment:

File Name: limesurvey...82_J.lss
File Size:26 KB


Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 2 months ago #192390 by tpartner
Replied by tpartner on topic Ranking question filtering
Nope, both will work.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose