For some reason the code that has worked on previous version doesn't seem to do that on 2.50. What should I do differently?
Is there a working solution for this?
<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 = 2;
// Identify this question
var qID = {QID};
// Find the number of answers
var ansCount = $('#question'+qID+' li.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 answer = $( 'input[id$="X'+qID+(ansCount-fixedIndex)+'"]');
var answerItem = $(answer).closest('li');
var answersList = $(answer).closest('ul');
$(answersList).append(answerItem);
fixedIndex--;
}
});
</script>
<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 = 2;
// 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 answer = $('input[id^="answer"][id$="X'+qID+(ansCount-fixedIndex)+'"]');
var answerItem = $(answer).closest('.answer-item');
var answersList = $(answer).closest('.answers-list');
if($('#question'+qID).hasClass('multiple-opt')) {
answerItem = $(answer).closest('.answer-item').parent();
answersList = $(answer).closest('.subquestion-list');
}
$(answersList).append(answerItem);
fixedIndex--;
}
});
</script>
Hi, thanks for all your help. It seems that i cannot make work this. I upload the example file and it doenst work. Maybe its a server problem or something that i have to change in the code.
I downloaded the 2.5 file. And theres nothing in the console. Its weird. Maybe its a setting on the app or the template You have to change something in the script to work? (qid?)
Im again with this problem. I change the server and cannot do it. I had imported the example and doest work.
Could you help me please?
gyts.ga/index.php/874188?lang=en
In that version, the IDs have changed slightly - use this script:
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 = 2;
// 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>