Welcome to the LimeSurvey Community Forum

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

Partially randomized answers (list radio type) in 2.50

  • tarantel999
  • tarantel999's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 8 months ago - 7 years 8 months ago #138854 by tarantel999
For some reason the code that has worked on previous version doesn't seem to do that on 2.50. What should I do differently?
Is there a working solution for this?

manual.limesurvey.org/Workarounds:_Manip...tions_.28Enhanced.29


Code:
<script type="text/javascript" charset="utf-8">  
 
  $(document).ready(function() {
 
    // The number of answers to be fixed at the end of the list
    var fixedAnswers = 2;
 
    // Identify this question
    var qID = {QID}; 
 
    // Find the number of answers
    var ansCount = $('#question'+qID+' li.answer-item').length;
 
    // Place the last n answers created at the end of the list
    var fixedIndex = fixedAnswers - 1;
    for (var i=0; i<fixedAnswers; i++) {
      var answer = $( 'input[id$="X'+qID+(ansCount-fixedIndex)+'"]');
      var answerItem = $(answer).closest('li');
      var answersList = $(answer).closest('ul');
      $(answersList).append(answerItem);
      fixedIndex--;
    }    
  });
</script>
Last edit: 7 years 8 months ago by tarantel999.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 8 months ago #138876 by tpartner
In LimeSurvey 2.50, you need to use this script:

Code:
<script type="text/javascript" charset="utf-8">  
 
  $(document).ready(function() {
 
    // The number of answers to be fixed at the end of the list
    var fixedAnswers = 2;
 
    // Identify this question
    var qID = {QID}; 
 
    // Find the number of answers
    var ansCount = $('#question'+qID+' .answer-item').length;
 
    // Place the last n answers created at the end of the list
    var fixedIndex = fixedAnswers - 1;
    for (var i=0; i<fixedAnswers; i++) {
      var answer = $('input[id^="answer"][id$="X'+qID+(ansCount-fixedIndex)+'"]');
      var answerItem = $(answer).closest('.answer-item');
      var answersList = $(answer).closest('.answers-list');
      if($('#question'+qID).hasClass('multiple-opt')) {
        answerItem = $(answer).closest('.answer-item').parent();
        answersList = $(answer).closest('.subquestion-list');
      }
      $(answersList).append(answerItem);
      fixedIndex--;
    }    
  });
</script>

I have updated the workaround accordingly - manual.limesurvey.org/Workarounds:_Manip...tions_.28Enhanced.29

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: vkuzmin
The topic has been locked.
More
7 years 8 months ago #139218 by gyts
Hi, thanks for all your help. It seems that i cannot make work this. I upload the example file and it doenst work. Maybe its a server problem or something that i have to change in the code.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 8 months ago #139221 by tpartner
Did you import the correct file? There is one for 2.06 and another for 2.5. Do you have any JavaScript errors in the console?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
7 years 8 months ago #139228 by gyts

I downloaded the 2.5 file. And theres nothing in the console. Its weird. Maybe its a setting on the app or the template You have to change something in the script to work? (qid?)
Attachments:
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 8 months ago #139229 by tpartner
Can you activate that survey and give a link?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
7 years 8 months ago #139230 by gyts
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 8 months ago - 7 years 8 months ago #139232 by tpartner
The workaround instructions say 'The "Show No answer" survey setting must be set to "No" ' - manual.limesurvey.org/Workarounds:_Manip...tions_.28Enhanced.29

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 7 years 8 months ago by tpartner.
The topic has been locked.
More
7 years 2 months ago #147457 by gyts
Im again with this problem. I change the server and cannot do it. I had imported the example and doest work.
Could you help me please?
gyts.ga/index.php/874188?lang=en
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 2 months ago #147468 by tpartner
You're not using the 2.50 script.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
7 years 2 months ago #147469 by gyts
im so stupid. I missread. Im sorry pal, thank for the patience
The topic has been locked.
More
6 years 4 months ago #160906 by blocka
I cannot get this to work on a list type (radio) question. It works fine when using multiple choice.

I've attached my LSS -- using LS version 2.72.4 build 171110

Can anyone help?
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose