Welcome to the LimeSurvey Community Forum

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

Partial randomization for ranking questions

  • cyclingdecisions
  • cyclingdecisions's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 9 months ago #155160 by cyclingdecisions
Partial randomization for ranking questions was created by cyclingdecisions
Hi!

I have a problem getting a ranking question partially randomized.

As I have three times the option 'other, please specify :<text>' I would like to randomize all factors except these three options. I found ways to do it for all kinds of questions but not for ranking questions in specific. Can anybody help me with this?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 9 months ago - 6 years 9 months ago #155163 by tpartner
Replied by tpartner on topic Partial randomization for ranking questions
Assuming, for the sake of example, you wanted to fix sub-question codes "SQ005", "SQ006" and "SQ007" at the end of the choices list, set up your survey to use JavaScript and place the following script in the source of the question:


Code:
<script type="text/javascript" charset="utf-8">
   $(document).ready(function() {
 
    // Identify this question code
    var qID = {QID}; 
 
    // Define the sub-question codes to be positioned last
    var sqCodes = ['SQ005', 'SQ006', 'SQ007']; 
 
    // Loop through those sq codes and place that sub-question at the end of the choices list
    $(sqCodes).each(function(i, code) {
      if($('#question'+qID+' .dragDropChoiceList li[id$="X'+qID+code+'"]').length > 0) {
        $('#question'+qID+' .dragDropChoiceList').append($('li[id$="X'+qID+code+'"]'));
      }
    });
  });
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 6 years 9 months ago by tpartner.
The topic has been locked.
  • cyclingdecisions
  • cyclingdecisions's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 9 months ago #155167 by cyclingdecisions
Replied by cyclingdecisions on topic Partial randomization for ranking questions
Thank you so much, this is exactly what I needed!!!
The topic has been locked.
  • Mazi
  • Mazi's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
2 months 1 day ago - 2 months 1 day ago #254675 by Mazi
For Limesurvey v5.x the code needs to be adjusted a little due to different CSS classes used there:
Code:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
 
// Identify this question code
var qID = {QID};
 
// Define the sub-question codes to be positioned last
var sqCodes = ['SQ005', 'SQ006', 'SQ007'];
 
// Loop through those sq codes and place that sub-question at the end of the choices list
$(sqCodes).each(function(i, code) {
if($('#question'+qID+' .sortable-choice li[id$="X'+qID+code+'"]').length > 0) {
$('#question'+qID+' .sortable-choice').append($('li[id$="X'+qID+code+'"]'));
}
});
});
</script>

Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
Last edit: 2 months 1 day ago by Mazi. Reason: Added code tag
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose