Partial Randomization Radio List - Beginner

More
3 weeks 7 hours ago #173425 by haroldrio
haroldrio created the topic: Partial Randomization Radio List - Beginner
Hi there.
I would like to ask for your help.
I am using limesurvey 3.xx

This is the 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 = 2;

// 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>


How can I modify this code.

I have turned off my html filtering already.
answer code are in numerical order too.


// Set this to "true" if you want "Other" to be fixed in the last position
var otherFixed = false;

// Identify this question
var qID = {QID}

changed the false to true
{QID} changed to {1333}

is that correct? how about the rest?
sorry I am a total newb to coding.

Please Log in or Create an account to join the conversation.

More
3 weeks 7 hours ago #173426 by haroldrio
haroldrio replied the topic: Partial Randomization Radio List - Beginner
I would appreciate if anyone can highlight those codes that needs to be replaced and a sample for each variable.

Thank you so much.

Please Log in or Create an account to join the conversation.

More
3 weeks 6 hours ago #173427 by tpartner
tpartner replied the topic: Partial Randomization Radio List - Beginner
The script given in the workaround page works as expected in LS 3.14.6.

Sample survey attached:

File Attachment:

File Name: limesurvey...9-04.lss
File Size:24 KB

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The following user(s) said Thank You: haroldrio

Please Log in or Create an account to join the conversation.

More
3 weeks 4 hours ago #173434 by haroldrio
haroldrio replied the topic: Partial Randomization Radio List - Beginner
Oh My. So this is the only 3 variables that needs to be changed.
Didn't know the right QID.

Thank you so much.
Now my survey is looking cool! B) B) B) B)

Please Log in or Create an account to join the conversation.

More
3 weeks 4 hours ago #173435 by haroldrio
haroldrio replied the topic: Partial Randomization Radio List - Beginner
Attachments:

Please Log in or Create an account to join the conversation.

More
3 weeks 3 hours ago #173445 by tpartner
tpartner replied the topic: Partial Randomization Radio List - Beginner
You do not need to modify {QID}, that will automatically be replaced with the question ID.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!