Welcome to the LimeSurvey Community Forum

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

Adding a number to rankings

More
5 years 1 month ago #202905 by tpartner
Can you attach a small sample survey (.lss file) containing only the relevant questions?

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
5 years 1 month ago #202912 by dostoyevski2015
Sure, please find it below. There are four pages in this trial survey: The first two of them are multiple short text questions. The third and the fourth pages are to rank those multiple short text answers. As you can see, the placeholder in the third page works well without the script. However, the script in the fourth page disrupts the placeholder function. I want to have both the script and the placeholder functions at the same time eventually.

p.s.: Sorry the buttons and so are in German

File Attachment:

File Name: limesurvey...5944.lss
File Size:35.26 KB
The topic has been locked.
More
5 years 1 month ago #202917 by holch
Replied by holch on topic Adding a number to rankings
By the way: LimeSurvey 2.67.3 is from 28.07.2017, so this version is almost 3 years old, unpatched, without updates. Even within the same branch, there have been newer versions, but this branch for sure has been one of the worst branches of Limesurvey with a lot of bugs, especially at the beginning.

I would highly recommend to update to LS 3.x LTS. Currently I would not use LS 4.x in production, as it has a similar history as 2.5x, which you are using.

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.
The topic has been locked.
More
5 years 1 month ago #202939 by tpartner
There appears to be a conflict between the script and Expression Manager in that version but I don't see where and see no JavaScript errors.

I also suggest updating your installation.

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
5 years 1 month ago #202942 by tpartner
Oh, wait, it's because Expression Manager is trying to parse the inserted styles. Use this script (note the inserted spaces after the opening curly braces of the style rules):

Code:
<script type="text/javascript" charset="utf-8">
  $(document).ready(function(){  
 
    // Identify this question
    var qID = {QID};
    var thisQuestion = $('#question'+qID);
 
    // Listeners on the rankable items
    $('.ui-sortable', thisQuestion).on('sortstop', function(event, ui) {
      insertRankIndicators();
    });      
    $('.ui-sortable li', thisQuestion).on('dblclick', function(event, ui) {
 
      setTimeout(function() {
        insertRankIndicators();
      }, 100);
    });
 
    // A function to insert ranking indicators
    function insertRankIndicators() {
      $('.inserted-rank', thisQuestion).remove();
      $('.dragDropRankList li', thisQuestion).each(function(i) {
        $(this).append('<span class="inserted-rank">Nr.'+(i+1)+'</span>');
      });
    }
 
    // Insert some styles (these could be in template.css)
    var newStyles = '.ui-sortable-handle { \
              position: relative;\
            }\
            .ui-sortable li .inserted-rank { \
              position: absolute;\
              top: 5px;\
              right: 5px;\
            }';  
    $('head').append('<style type="text/css">'+newStyles+'</style>');  
  });    
</script>

Sample survey attached:

File Attachment:

File Name: limesurvey...4(3).lss
File Size:35 KB

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: dostoyevski2015
The topic has been locked.
More
5 years 1 month ago #202967 by dostoyevski2015
That works, Tony, thanks!

You both are right, that this version needs to be updated. I just need to use it as my institution does (bureaucratic hurdles...)
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose