- Posts: 5
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
Please Log in to join the conversation.
The following question retains the same order as the first one instead of randomizing independently.
Please Log in to join the conversation.
...only the first question displays randomized subquestions. The following question retains the same order as the first one instead of randomizing independently..
<script type="text/javascript" data-author="Tony Partner"> 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:scriptcomplete',function(){ // Identify the questions var qID = '{QID}'; var thisQuestion = $('#question'+qID); var textQuestion = thisQuestion.nextAll('.text-short:eq(0)'); var textInput = $('input:text.form-control:eq(0)', textQuestion); // Hide the text question textQuestion.hide(); var sqCodes = []; // First visit if($.trim(textInput.val()) == '') { // Get all sub-question codes $($('tr[id^="javatbd"]', thisQuestion)).each(function(i) { sqCodes.push($(this).attr('id').split('X'+qID)[1]); }); // Randomize the sub-question codes shuffleArray(sqCodes) // Load the sub-question codes into the hidden short-text question textInput.val(sqCodes) } // Returning to the page else { sqCodes = $.trim(textInput.val()).split(','); } // Insert the random sub-questions $.each(sqCodes, function(i, sqCode) { $($('table.subquestion-list tbody:eq(0)', thisQuestion)).append($('tr[id$="X'+qID+sqCode+'"]', thisQuestion)); }); }); </script>
Please Log in to join the conversation.
Please Log in to join the conversation.
In this case you should have a look at the source code.I’m asking to understand this better and to see if there might be another possible workaround.
You see, only in an active survey there is a record in the database where the "seed" is stored.and as to why randomization is independent when I preview the survey.
Please Log in to join the conversation.
Please Log in to join the conversation.