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 thisQuestion = $('[id^=question]');
    var thisQuestion = $('.array-flexible-column:eq(0)'); 

	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);
	});
});
    
$(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);
  });
});
