I know that there is already a script to fix the last answer option when you randomize it. Does anyone of you know if there is another scritp / workaround to fix the first answer option and all other options are still randomizing?
Hi,
no other script.
Just some kind of adaption.
If the script uses the function "append" to fix an item at the bottom, so why not try to use "prepend" to fix it at the top.
So replace the "append" in this line $(answersList).append(answerItem);
to $(answersList).prepend(answerItem);
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 listvar fixedAnswers =1;// Set this to "true" if you want "Other" to be fixed in the last positionvar otherFixed =false;// Identify this questionvar qID ={QID};// Find the number of answersvar 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 listvar 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).prepend(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>
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless