- Posts: 171
- Thank you received: 27
Ask the community, share ideas, and connect with other LimeSurvey users!
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
<script type="text/javascript"> $(document).on('ready pjax:scriptcomplete',function(){ function shuffleArray(array) { for (var i = array.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)); var temp = array; array = array[j]; array[j] = temp; } return array; } //Identify this question var thisQuestion = $('#question{QID}'); var thisAnswerList = $('tr.answers-list:eq(0)', thisQuestion).parent(); // Create the arrays with "normal" codes var array1=[2,3,4]; var array2=[6,7,8,9]; var array3=[11,12]; var arrayG=; // Shuffle the arrays shuffleArray(array1); shuffleArray(array2); shuffleArray(array3); // Add the Header code array1.unshift(1); array2.unshift(5); array3.unshift(10); // Create a random number (1-6) var rn=Math.floor(Math.random() * 6 + 1); if(rn==1) { arrayG=array1.concat(array2,array3); } if(rn==2) { arrayG=array1.concat(array3,array2); } if(rn==3) { arrayG=array2.concat(array1,array3); } if(rn==4) { arrayG=array2.concat(array3,array1); } if(rn==5) { arrayG=array3.concat(array1,array2); } if(rn==6) { arrayG=array3.concat(array2,array1); } // Add the "other"code arrayG.push('other'); $('input:text', thisQuestion).val(arrayG); }); </script>
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ //Identify this question var thisQuestion = $('#question{QID}'); var thisAnswerList = $('li.answer-item:eq(0)', thisQuestion).parent(); // Retrieve the answer codes from the "randomOrder" question var answerCodes = '{QOrder}'.split(','); // Loop through the answer codes $.each(answerCodes, function(i, val) { // Move the answer item $(thisAnswerList).append($('li.answer-item[id$="X{QID}'+val+'"]', thisQuestion)); }); }); </script>
Please Log in to join the conversation.
<script charset="utf-8" type="text/javascript"> $(document).ready(function() { var answerCodes = '{QOrder}'.split(','); var x1 = answerCodes.indexOf("1"); var x5 = answerCodes.indexOf("5"); var x10 = answerCodes.indexOf("10"); $( '#question{QID} .question-item:eq(0)').addClass('hide-pseudo-elements').find('input.checkbox').remove(); if(x1==3) { $( '#question{QID} .question-item:eq(3)').addClass('hide-pseudo-elements').find('input.checkbox').remove(); } if(x1==5) { $( '#question{QID} .question-item:eq(5)').addClass('hide-pseudo-elements').find('input.checkbox').remove(); } if(x1==8) { $( '#question{QID} .question-item:eq(8)').addClass('hide-pseudo-elements').find('input.checkbox').remove(); } if(x5==3) { $( '#question{QID} .question-item:eq(3)').addClass('hide-pseudo-elements').find('input.checkbox').remove(); } if(x5==4) { $( '#question{QID} .question-item:eq(4)').addClass('hide-pseudo-elements').find('input.checkbox').remove(); } if(x5==7) { $( '#question{QID} .question-item:eq(7)').addClass('hide-pseudo-elements').find('input.checkbox').remove(); } if(x10==4) { $( '#question{QID} .question-item:eq(4)').addClass('hide-pseudo-elements').find('input.checkbox').remove(); } if(x10==5) { $( '#question{QID} .question-item:eq(5)').addClass('hide-pseudo-elements').find('input.checkbox').remove(); } if(x10==9) { $( '#question{QID} .question-item:eq(9)').addClass('hide-pseudo-elements').find('input.checkbox').remove(); } }); </script>
<style type="text/css">.hide-pseudo-elements label::before, .hide-pseudo-elements label::after { display: none; } .hide-pseudo-elements .label-text { margin-left: -40px; } </style>
Please Log in to join the conversation.
Please Log in to join the conversation.
<script charset="utf-8" type="text/javascript"> $(document).ready(function() { var answerCodes = '{QOrder}'.split(','); var x1 = answerCodes.indexOf("1"); var x5 = answerCodes.indexOf("5"); var x10 = answerCodes.indexOf("10"); $( '#question{QID} .question-item:eq('+x1+')').addClass('hide-pseudo-elements').find('input.checkbox').remove(); $( '#question{QID} .question-item:eq('+x5+')').addClass('hide-pseudo-elements').find('input.checkbox').remove(); $( '#question{QID} .question-item:eq('+x10+')').addClass('hide-pseudo-elements').find('input.checkbox').remove(); }); </script>
Please Log in to join the conversation.