- Posts: 31
- Thank you received: 2
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Multilingual surve: sorting responses alphabetically in a 2nd, 3rd language ?
- karld
- Topic Author
- Offline
- Junior Member
Less
More
10 years 15 hours ago - 10 years 15 hours ago #107816
by karld
Multilingual surve: sorting responses alphabetically in a 2nd, 3rd language ? was created by karld
Hello,
I have a survey with 2 languages:
Thanks in advance,
--
Carl
I have a survey with 2 languages:
- in the main language, the answers of a question (e.g. multiple choice) are sorted alphabetically (I did it when designing the question)
- How can I have the answers sorted alphabetically in the second language?
Thanks in advance,
--
Carl
Last edit: 10 years 15 hours ago by karld.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
9 years 11 months ago - 9 years 11 months ago #107852
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Multilingual surve: sorting responses alphabetically in a 2nd, 3rd language ?
You will need to use a little JavaScript to move those around.
Here's a solution for list-radio and multiple-choice questions
1) Set up your survey to use JavaScript .
2) Add this function to the end of template.js:
3) Add this script to the source of every question that you want sorted (in all languages to be sorted):
.
Here's a solution for list-radio and multiple-choice questions
1) Set up your survey to use JavaScript .
2) Add this function to the end of template.js:
Code:
function sortOptions(qID) { // Identify this question var thisQuestion = $('#question'+qID); // Create an array of subquestions var subQsArr = new Array(); $('li.answer-item', thisQuestion).each(function(i) { var thisString = $(this).find('.answertext').text()+'---'+$(this).attr('id'); subQsArr.push(thisString); }); // Sort the array subQsArr.sort(); // Repostion the subquestions in the sorted order $(subQsArr).each(function(i, val) { var thisID = val.split('---')[1]; $('li.answer-item:eq(0)', thisQuestion).parent().append($('#'+thisID)); }); }
3) Add this script to the source of every question that you want sorted (in all languages to be sorted):
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { sortOptions({QID}); }); </script>
.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 9 years 11 months ago by tpartner.
The following user(s) said Thank You: karld
The topic has been locked.
- karld
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 31
- Thank you received: 2
9 years 11 months ago #107883
by karld
Replied by karld on topic Multilingual surve: sorting responses alphabetically in a 2nd, 3rd language ?
Thank you very much.
I have tried it on a radio buttons list question, it works fine, but the "other" with a textbox is also sorted.
I have tried it on a radio buttons list question, it works fine, but the "other" with a textbox is also sorted.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
9 years 11 months ago #107890
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Multilingual surve: sorting responses alphabetically in a 2nd, 3rd language ?
Oh, yeah, forgot that. Use this as the function in template.js:
Code:
function sortOptions(qID) { // Identify this question var thisQuestion = $('#question'+qID); // Create an array of subquestions var subQsArr = new Array(); $('li.answer-item', thisQuestion).each(function(i) { var thisString = $(this).find('.answertext').text()+'---'+$(this).attr('id'); subQsArr.push(thisString); }); // Sort the array subQsArr.sort(); // Repostion the subquestions in the sorted order $(subQsArr).each(function(i, val) { var thisID = val.split('---')[1]; $('li.answer-item:eq(0)', thisQuestion).parent().append($('#'+thisID)); }); $('li.answer-item:eq(0)', thisQuestion).parent().append($('li.answer-item[id$="other"]', thisQuestion)); }
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: karld
The topic has been locked.
- karld
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 31
- Thank you received: 2
9 years 11 months ago - 9 years 11 months ago #107900
by karld
Replied by karld on topic Multilingual survey: sorting responses alphabetically in a 2nd, 3rd language ?
Great ! It works as expected.
Many thanks.
Many thanks.
Last edit: 9 years 11 months ago by karld.
The topic has been locked.
- ymca
- Offline
- Elite Member
Less
More
- Posts: 168
- Thank you received: 2
3 years 11 months ago #197945
by ymca
LS Version 4.2+
Replied by ymca on topic Multilingual survey: sorting responses alphabetically in a 2nd, 3rd language ?
Hi,
I've also tried that, but it didn't work for me.
Version 4.2.0+200422
I've also tried that, but it didn't work for me.
Version 4.2.0+200422
LS Version 4.2+
The topic has been locked.
- ymca
- Offline
- Elite Member
Less
More
- Posts: 168
- Thank you received: 2
3 years 11 months ago #197946
by ymca
Maybe the problem is here?
I've insert the text from here to the empty "costum.js" because "templet.js" had a warning not to edit.
LS Version 4.2+
Replied by ymca on topic Multilingual survey: sorting responses alphabetically in a 2nd, 3rd language ?
ymca wrote: Hi,
I've also tried that, but it didn't work for me.
Version 4.2.0+200422
Maybe the problem is here?
I've insert the text from here to the empty "costum.js" because "templet.js" had a warning not to edit.
tpartner wrote: Oh, yeah, forgot that. Use this as the function in template.js:
Code:function sortOptions(qID) { // Identify this question var thisQuestion = $('#question'+qID); // Create an array of subquestions var subQsArr = new Array(); $('li.answer-item', thisQuestion).each(function(i) { var thisString = $(this).find('.answertext').text()+'---'+$(this).attr('id'); subQsArr.push(thisString); }); // Sort the array subQsArr.sort(); // Repostion the subquestions in the sorted order $(subQsArr).each(function(i, val) { var thisID = val.split('---')[1]; $('li.answer-item:eq(0)', thisQuestion).parent().append($('#'+thisID)); }); $('li.answer-item:eq(0)', thisQuestion).parent().append($('li.answer-item[id$="other"]', thisQuestion)); }
LS Version 4.2+
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12902
- Thank you received: 3967
3 years 11 months ago #197956
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Multilingual survey: sorting responses alphabetically in a 2nd, 3rd language ?
This thread started 6 years ago.
So, how can you expect a script, that was obviously created for a previous version (maybe 1.92 or 2.05) , to run.
Nowadays we have the option:
Sort answers alphabetically
that works fine in version 3.x
even in drop downs
But obviously there is a bug in version 4.x.
You should file a bug report
So, how can you expect a script, that was obviously created for a previous version (maybe 1.92 or 2.05) , to run.
Nowadays we have the option:
Sort answers alphabetically
that works fine in version 3.x
even in drop downs
But obviously there is a bug in version 4.x.
You should file a bug report
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Attachments:
The topic has been locked.
- ymca
- Offline
- Elite Member
Less
More
- Posts: 168
- Thank you received: 2
3 years 11 months ago #197967
by ymca
LS Version 4.2+
Replied by ymca on topic Multilingual survey: sorting responses alphabetically in a 2nd, 3rd language ?
Wasn't expecting, was hoping.Joffm wrote: This thread started 6 years ago.
So, how can you expect a script, that was obviously created for a previous version (maybe 1.92 or 2.05) , to run.
Sure.You should file a bug report
LS Version 4.2+
The topic has been locked.