Partial Randomization Radio List - Beginner

Mehr
1 Jahr 1 Woche her #173425 von haroldrio
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.
Folgende Benutzer bedankten sich: neraunzaran

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

LimeSurvey Partners
Mehr
1 Jahr 1 Woche her #173426 von haroldrio
I would appreciate if anyone can highlight those codes that needs to be replaced and a sample for each variable.

Thank you so much.

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
1 Jahr 1 Woche her #173427 von tpartner
The script given in the workaround page works as expected in LS 3.14.6.

Sample survey attached:

Dateianhang:

Dateiname: limesurvey...9-04.lss
Dateigröße:24 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com
Anhänge:
Folgende Benutzer bedankten sich: haroldrio

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
1 Jahr 1 Woche her #173434 von haroldrio
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)

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
1 Jahr 1 Woche her #173435 von haroldrio
Anhänge:

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
1 Jahr 1 Woche her #173445 von tpartner
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.
Official LimeSurvey Partner - partnersurveys.com
Folgende Benutzer bedankten sich: DenisChenu

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
9 Monate 3 Tage her - 3 Monate 2 Wochen her #178184 von haroldrio
This is for my future reference.
I keep coming back to this post and forgot some few details.
Thank you so much Tpartner for the Help.



So this is the right code that worked on my Limesurvey 3.2.1

conditions are as follows:
Global Setting - Security is set to XSS OFF
Radio List
- Randomize on each page load
- No answer option is Turned OFF
- Answer Code should be sequential
- Fixed answer is only changed. (Qid is automatically changed -credits to Tpartner)

This is the code::
<script type="text/javascript" charset="utf-8">	
 
	$(document).ready(function() {
 
		// The number of answers to be fixed at the end of the list
		var fixedAnswers = [color=red][b][size=5]2[/size][/b][/color];
 
		// Identify this question
		var qID = {QID}; 
 
		// Find the number of answers
		var ansCount = $('#question'+qID+' .answer-item').length;
 
		// Place the last n answers created at the end of the list
		var fixedIndex = fixedAnswers - 1;
		for (var i=0; i<fixedAnswers; i++) {
			var answerItem = $('.answer-item[id^="javatbd"][id$="X'+qID+(ansCount-fixedIndex)+'"]');
			if($('#question'+qID).hasClass('multiple-opt')) {
				$(answerItem).closest('.subquestion-list').append($(answerItem).parent());
			}
			else {
				$(answerItem).closest('.answers-list').append(answerItem);
			}
			fixedIndex--;
		}		
	});
</script>
Letzte Änderung: 3 Monate 2 Wochen her von DenisChenu. Begründung: code tag
Folgende Benutzer bedankten sich: neraunzaran

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
3 Monate 2 Wochen her #185043 von neraunzaran
Thanks haroldio, i will keep this for future reference too.

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Jetzt loslegen!

Melden Sie sich jetzt an, und erstellen Sie in wenigen Minuten Ihre erste Umfrage.

Account einrichten

Abonnieren Sie unseren Newsletter

Abonnieren Sie unseren Newsletter für alle Neuigkeiten rund um LimeSurvey
captcha