Welcome to the LimeSurvey Community Forum

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

Survey permission

  • nohcho82
  • nohcho82's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 5 months ago #143963 by nohcho82
Survey permission was created by nohcho82
Hello,

Is it possible to sort by full name in user list selection for survey permission?
For example from this picture:
Default is order by username.
In this case username is' limesurv' and full mane is 'administrator'



many thanks
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 5 months ago #143968 by tpartner
Replied by tpartner on topic Survey permission
1) Create your own admin template with a custom JavaScript file - www.limesurvey.org/forum/can-i-do-this-w...in-admin-page#137765

2) Insert something like this into the custom JavaScript file. It will sort the list options by their strings split at the first space.

Code:
$(document).ready(function(){
 
  // Sort the user list in "Survey permissions"
  if($('#uidselect').length > 0) {
    var userList = $('#uidselect');
 
    var userOptions = $('option', userList);
    var selectedOption = $(userList).val();
 
    // Case insensitive sort
    // Options sorted by string split at the first space
    /*
    userOptions.sort(function(a,b) {
      if (a.text.replace(/^([^\s]+)\s(.+)$/,"$2 $1").toLowerCase() > b.text.replace(/^([^\s]+)\s(.+)$/,"$2 $1").toLowerCase()) return 1;
      if (a.text.replace(/^([^\s]+)\s(.+)$/,"$2 $1").toLowerCase() < b.text.replace(/^([^\s]+)\s(.+)$/,"$2 $1").toLowerCase()) return -1;
      return 0
    });
    */
 
    // Case sensitive sort
    // Options sorted by string split at the first space   
    userOptions.sort(function(a,b) {
      if (a.text.replace(/^([^\s]+)\s(.+)$/,"$2 $1") > b.text.replace(/^([^\s]+)\s(.+)$/,"$2 $1")) return 1;
      if (a.text.replace(/^([^\s]+)\s(.+)$/,"$2 $1") < b.text.replace(/^([^\s]+)\s(.+)$/,"$2 $1")) return -1;
      return 0
    });
 
    $(userList).empty().append(userOptions);
    $(userList).prepend($('option[value="-1"]', userList));
    $(userList).val(selectedOption);
  }  
});

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • nohcho82
  • nohcho82's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 5 months ago - 7 years 5 months ago #143976 by nohcho82
Replied by nohcho82 on topic Survey permission
I did it step by spep but still the same:(
I juist copy/paste this code to my new JS file. Did I something wrong?
Last edit: 7 years 5 months ago by nohcho82.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 5 months ago #144003 by tpartner
Replied by tpartner on topic Survey permission
That script is for version 2.06 LTS. What is your LimeSurvey version?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • nohcho82
  • nohcho82's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 5 months ago #144006 by nohcho82
Replied by nohcho82 on topic Survey permission
2.05+ build 141020
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 5 months ago #144015 by tpartner
Replied by tpartner on topic Survey permission
Hmm...it works for me in 2.05.


Do you have any JavaScript errors in the console. Can you get a simple JavaScript alert to 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.
  • nohcho82
  • nohcho82's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 5 months ago #144019 by nohcho82
Replied by nohcho82 on topic Survey permission
hier are screenshots





The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 5 months ago #144020 by tpartner
Replied by tpartner on topic Survey permission
I ask again. Do you have any JavaScript errors in the console. Can you get a simple JavaScript alert to 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.
  • nohcho82
  • nohcho82's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 5 months ago #144021 by nohcho82
Replied by nohcho82 on topic Survey permission
No, I get no errors in the console. I created a simple JavaScript alert, its works.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 5 months ago #144023 by tpartner
Replied by tpartner on topic Survey permission
I'm sorry then, I can't explain why it works for me but not for you.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • nohcho82
  • nohcho82's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 5 months ago #144025 by nohcho82
Replied by nohcho82 on topic Survey permission
Default is sort by user_name. It is not possible just change the default code to sort by full_name? Where can I find the file with default code?
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose