- Posts: 162
- Thank you received: 14
Ask the community, share ideas, and connect with other LimeSurvey users!
$(document).ready(function() { // Identify the questions -- FOR DISC var thisQuestion = $('[id^=question]'); // Listener on the radios $('input.radio', thisQuestion).on('click', function(e) { $('input[type="radio"]', thisQuestion).prop('disabled', false); $('input.radio:checked', thisQuestion).each(function(i) { $(this).closest('tr.answers-list').find('input[type="radio"]').not(this).prop('disabled', true); }); }); // Initial settings $('input.radio:checked', thisQuestion).each(function(i) { $(this).closest('tr.answers-list').find('input[type="radio"]').not(this).prop('disabled', true); }); });
<script type="text/javascript" charset="utf-8"> function shuffleArray(array) { for (var i = array.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)); var temp = array[i]; array[i] = array[j]; array[j] = temp; } return array; } $(document).on('ready pjax:complete',function() { // Identify this question var thisQuestion = $('#question{QID}'); var elements = $('tr.answers-list', thisQuestion).detach().toArray(); shuffleArray(elements); $('tr.answers-list', thisQuestion).remove(); $.each(elements, function(i, el) { $('table.subquestion-list tbody:eq(0)', thisQuestion).append(el); }); }); </script>
var thisQuestion = $('.array-flexible-column:eq(0)');
<script type="text/javascript" charset="utf-8"> function shuffleArray(array) { for (var i = array.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)); var temp = array[i]; array[i] = array[j]; array[j] = temp; } return array; } $(document).on('ready pjax:complete',function() { // Identify this question var thisQuestion = $('#question{QID}'); var elements = $('tr.answers-list', thisQuestion).detach().toArray(); shuffleArray(elements); $('tr.answers-list', thisQuestion).remove(); $.each(elements, function(i, el) { $('table.subquestion-list tbody:eq(0)', thisQuestion).append(el); }); // The answer code to place in the last position var fixedCode = 'A4'; // Move the "fixed" row to the end $('table.subquestion-list tbody:eq(0), table.subquestions-list tbody:eq(0)', thisQuestion).append($('tr[id$="X'+{QID}+fixedCode +'"]')); // Fix up the array row background colours $('table.subquestion-list tbody tr, table.subquestions-list tbody tr', thisQuestion).each(function(i){ $(this).removeClass('array1 array2').addClass('array'+(2-(i%2))); }); }); </script>
<script type="text/javascript" charset="utf-8"> function shuffleArray(array) { for (var i = array.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)); var temp = array[i]; array[i] = array[j]; array[j] = temp; } return array; } $(document).on('ready pjax:complete',function() { // Identify this question var thisQuestion = $('#question{QID}'); var elements = $('tr.answers-list', thisQuestion).detach().toArray(); shuffleArray(elements); $('tr.answers-list', thisQuestion).remove(); $.each(elements, function(i, el) { $('table.subquestion-list tbody:eq(0)', thisQuestion).append(el); }); // The answer code to place in the last position var fixedCode = 'A4'; // Move the "fixed" row to the end $('table.subquestion-list tbody:eq(0), table.subquestions-list tbody:eq(0)', thisQuestion).append($('tr[id="javatbd'+fixedCode +'"]')); }); </script>