- Posts: 139
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
Please Log in to join the conversation.
<script type="text/javascript" charset="utf-8"> function shuffle(array) { var currentIndex = array.length, temporaryValue, randomIndex; // While there remain elements to shuffle... while (0 !== currentIndex) { // Pick a remaining element... randomIndex = Math.floor(Math.random() * currentIndex); currentIndex -= 1; // And swap it with the current element. temporaryValue = array[currentIndex]; array[currentIndex] = array[randomIndex]; array[randomIndex] = temporaryValue; } return array; } $(document).on('ready pjax:scriptcomplete',function(){ // Fill the arrays var arrTopFix = [1,2] ; var arrRand = [3,4,5,6]; var arrBottomFix = [7] ; var arrTotal = ; arrTopFix = arrTopFix.join(','); arrRand = shuffle(arrRand).join(',');; arrBottomFix = arrBottomFix.join(','); arrTotal=arrTopFix.concat(',',arrRand,',',arrBottomFix); $('#question{QID} input[type="text"]').val(arrTotal); // Nach dem Testen in dieser letzten Zeile die Schrägstriche entfernen //$('#question{QID}').hide(); }); </script>
<script type="text/javascript" data-author="Tony Partner"> $(document).on('ready pjax:scriptcomplete',function(){ //Identify this question var thisQuestion = $('#question{QID}'); var thisAnswerList = $('tr.answers-list:eq(0)', thisQuestion).parent(); // Retrieve the answer codes from the "randOrder" question var answerCodes = '{randOrder}'.split(','); // Loop through the answer codes $.each(answerCodes, function(i, val) { // Move the answer item $(thisAnswerList).append($('tr.answers-list[id$="X{QID}'+val+'"]', thisQuestion)); }); }); </script>
Please Log in to join the conversation.