- Posts: 10
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Fixing answer in the end of randomised list, for a multiple column display
- evhenii_access
- Topic Author
- Offline
- New Member
Less
More
4 weeks 19 hours ago #259192
by evhenii_access
Fixing answer in the end of randomised list, for a multiple column display was created by evhenii_access
Please help us help you and fill where relevant:
Your LimeSurvey version: [ LimeSurvey Cloud Version 6.4.12]
Own server or LimeSurvey hosting: LimeSurvey hosting
Survey theme/template: Fruity TwentyThree
==================
Hi, I would appreciate some help with javascript code forcing an answer option (like ‘None’) to be always show in the end of randomized list with multiple columns.I’ve been using this javascript code below (found on this forum) placed in ‘question text’ section – it works just fine, but only for a 1-column display. However, for 2-column or 3-column display, this code makes ‘None’ to be shown on the page 2 or 3 times – in the end of each column. I’m attaching the lss archive with example of 3-column and 1-column design.Could anyone help me please to adjust this code for 2-column and 3-column list, so that ‘None’ is shown just once, in the end of last column? <script type='text/javascript'>/* Place option at the end of the randomized list */$(document).ready(function() {var move_element="C701";/* Please do NOT change the lines below */var move_element="javatbd{SGQ}"+move_element;$("#"+move_element).insertAfter("#question{QID} .answers-list .answer-item:last-child");});</script>
Your LimeSurvey version: [ LimeSurvey Cloud Version 6.4.12]
Own server or LimeSurvey hosting: LimeSurvey hosting
Survey theme/template: Fruity TwentyThree
==================
Hi, I would appreciate some help with javascript code forcing an answer option (like ‘None’) to be always show in the end of randomized list with multiple columns.I’ve been using this javascript code below (found on this forum) placed in ‘question text’ section – it works just fine, but only for a 1-column display. However, for 2-column or 3-column display, this code makes ‘None’ to be shown on the page 2 or 3 times – in the end of each column. I’m attaching the lss archive with example of 3-column and 1-column design.Could anyone help me please to adjust this code for 2-column and 3-column list, so that ‘None’ is shown just once, in the end of last column? <script type='text/javascript'>/* Place option at the end of the randomized list */$(document).ready(function() {var move_element="C701";/* Please do NOT change the lines below */var move_element="javatbd{SGQ}"+move_element;$("#"+move_element).insertAfter("#question{QID} .answers-list .answer-item:last-child");});</script>
Please Log in to join the conversation.
- Joffm
- Away
- LimeSurvey Community Team
Less
More
- Posts: 12941
- Thank you received: 3979
4 weeks 18 hours ago #259195
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Fixing answer in the end of randomised list, for a multiple column display
Hi,
here you find a working script.
[url] manual.limesurvey.org/Workarounds:_Manip...meSurvey_version_3.x :[/url]
And don't miss this
Create a Multiple Options or List (radio) question with sequential response codes.
Where did you find your script. I did not find the source of it, only citations.
Joffm
here you find a working script.
[url] manual.limesurvey.org/Workarounds:_Manip...meSurvey_version_3.x :[/url]
And don't miss this
Create a Multiple Options or List (radio) question with sequential response codes.
Where did you find your script. I did not find the source of it, only citations.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Please Log in to join the conversation.
- evhenii_access
- Topic Author
- Offline
- New Member
Less
More
- Posts: 10
- Thank you received: 0
4 weeks 16 hours ago #259212
by evhenii_access
Replied by evhenii_access on topic Fixing answer in the end of randomised list, for a multiple column display
Hi, many thanks for referring me to the right source of workarounds. However, I still wasn’t able to fix the issue, as there are multiple pieces of code which could do the job, but none of them works properly for 3 columns.I want ‘None’ to be placed in the end of last column, but it’s randomly placed in the end of 1st or 2nd or 3rd column. If I try to have 2 variants in the end – they are placed in the end of some random column or columns.I’ve tried these 4 variands of code - - Partially Randomized Answers - Multiple Options & List (radio) questions- Partially Randomized Answers - Multiple Options & List (radio) questions (Enhanced) - LimeSurvey version 2.06, LimeSurvey version 2.73.0, LimeSurvey version 3.xCould you please point out or paste here the specific piece of code that you were able to use successfully in your example? Does it work properly in every run, with None always placed in last column? Many thanks again
Please Log in to join the conversation.
- Joffm
- Away
- LimeSurvey Community Team
Less
More
- Posts: 12941
- Thank you received: 3979
4 weeks 14 hours ago - 4 weeks 14 hours ago #259241
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Fixing answer in the end of randomised list, for a multiple column display
You are right, the link is broken. It leads to the wrong script
Use this script in
Partially Randomized Answers - Multiple Options & List (radio) questions (Enhanced)
LimeSurvey version 3.x:
Use this script in
Partially Randomized Answers - Multiple Options & List (radio) questions (Enhanced)
LimeSurvey version 3.x:
Code:
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ // The number of answers to be fixed at the end of the list var fixedAnswers = 1; // Set this to "true" if you want "Other" to be fixed in the last position var otherFixed = false; // Identify this question var qID = {QID}; // Find the number of answers var ansCount = $('#question'+qID+' .answer-item').length; if($('#question'+qID+' input[type="text"]').length > 0) { ansCount = ansCount -1 } console.log(ansCount); // 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('ul'); $(answersList).append(answerItem); fixedIndex--; } // Handle "Other" if(otherFixed == true && $('#question'+qID+' input[type="text"]').length > 0) { var otherAnswer = $('#question'+qID+' input[type="text"]'); var otherAnswerItem = $(otherAnswer ).closest('.answer-item'); var otherAnswersList = $(otherAnswer ).closest('ul'); $(otherAnswersList).append(otherAnswerItem); } }); </script>
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 4 weeks 14 hours ago by Joffm.
Please Log in to join the conversation.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
4 weeks 14 hours ago #259244
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 Fixing answer in the end of randomised list, for a multiple column display
More inspiration here -
forums.limesurvey.org/forum/can-i-do-thi...-with-columns#255824
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: evhenii_access
Please Log in to join the conversation.
- evhenii_access
- Topic Author
- Offline
- New Member
Less
More
- Posts: 10
- Thank you received: 0
4 weeks 14 hours ago #259245
by evhenii_access
Replied by evhenii_access on topic Fixing answer in the end of randomised list, for a multiple column display
This code pasted above (from Partially Randomized Answers - Multiple Options & List (radio) questions (Enhanced), LimeSurvey version 3.x) is not working for me at all - neither for 1 column, not for 2 or 3 columns display: the last answer 'None' appears in a totally random position in the middle of the list.
I've also tried other variants of code in this section Partially Randomized Answers - Multiple Options & List (radio) questions (Enhanced) - these two - LimeSurvey version 2.06 and LimeSurvey version 2.73.0. For 1 column they work fine, but for 3 columns they fail - they put 'None' in end position in some random column (1st or 2nd or 3rd).
I've also tried other variants of code in this section Partially Randomized Answers - Multiple Options & List (radio) questions (Enhanced) - these two - LimeSurvey version 2.06 and LimeSurvey version 2.73.0. For 1 column they work fine, but for 3 columns they fail - they put 'None' in end position in some random column (1st or 2nd or 3rd).
Please Log in to join the conversation.
- Joffm
- Away
- LimeSurvey Community Team
Less
More
- Posts: 12941
- Thank you received: 3979
4 weeks 13 hours ago #259248
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Fixing answer in the end of randomised list, for a multiple column display
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Please Log in to join the conversation.
- evhenii_access
- Topic Author
- Offline
- New Member
Less
More
- Posts: 10
- Thank you received: 0
4 weeks 13 hours ago #259249
by evhenii_access
Replied by evhenii_access on topic Fixing answer in the end of randomised list, for a multiple column display
Thank you very much! This worked for me
Please Log in to join the conversation.
- evhenii_access
- Topic Author
- Offline
- New Member
Less
More
- Posts: 10
- Thank you received: 0
4 weeks 13 hours ago #259250
by evhenii_access
Replied by evhenii_access on topic Fixing answer in the end of randomised list, for a multiple column display
Sure, here is the lss export with the suggested code, which does not seem to be working. Thank you!
Attachments:
Please Log in to join the conversation.
- Joffm
- Away
- LimeSurvey Community Team
Less
More
- Posts: 12941
- Thank you received: 3979
4 weeks 13 hours ago #259252
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Fixing answer in the end of randomised list, for a multiple column display
Hi,
beware that this
// Handle "Other"
if(otherFixed == true && $('#question'+qID+' input[type="text"]').length > 0) {
is not changed to
// Handle "Other"
if(otherFixed == true && $('#question'+qID+' input[type="text"]').length > 0) {
as in your sample.
And change the exclusive option to the correct value.
beware that this
// Handle "Other"
if(otherFixed == true && $('#question'+qID+' input[type="text"]').length > 0) {
is not changed to
// Handle "Other"
if(otherFixed == true && $('#question'+qID+' input[type="text"]').length > 0) {
as in your sample.
And change the exclusive option to the correct value.
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: evhenii_access
Please Log in to join the conversation.
- evhenii_access
- Topic Author
- Offline
- New Member
Less
More
- Posts: 10
- Thank you received: 0
4 weeks 10 hours ago #259256
by evhenii_access
Replied by evhenii_access on topic Fixing answer in the end of randomised list, for a multiple column display
Joffm and tpartner - thank you both so much for your prompt response and great help! So I now have two versions of script working correctly for this issue.
Please Log in to join the conversation.