- Posts: 62
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
Please Log in to join the conversation.
Es nützt allerdings überhaupt nichts, wenn sich nur eine einzige Frage in der Randomisierungsgruppe befindet.Um Reihenfolge-Effekte auszuschließen, werden Blöcke in der Reihenfolge randomisiert. Dies mache ich über die Funktion "Randomization group name". Auch das funktioniert wunderbar.
// Call the maxDiff() function // Set the second parameter to true for randomized rows maxDiff({QID}, true);
Die Frage "maxDiff2q1" hat die Nummer 5 (qseq und gseq beginnen ja bei 0){list(maxDiff2q1_SQ001.qseq,maxDiff2q1_SQ002.qseq)}
Hast Du doch bei der ersten MaxDiff-Frage auch.Auf der zweiten Frageseite habe ich es über den Fragetyp Array by column versucht
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" charset="utf-8"> function maxDiff(qID, randomize) { var thisQuestion = $('#question' + qID); var thisTable = $('table.subquestion-list:eq(0)', thisQuestion); var thisTbody = $('tbody', thisTable); // Short-Text-Frage direkt nach der MaxDiff-Frage var hiddenQuestion = $(thisQuestion).nextAll('.text-short:eq(0)'); var hiddenInput = $('input:text', hiddenQuestion); $(thisQuestion).addClass('max-diff-array'); // Move the columns $('thead tr:eq(0)', thisTable).prepend($('thead tr:eq(0) th:eq(1)', thisTable)); $('tr.answers-list', thisTable).each(function(i) { $('td.answer-item:eq(0)', this).prependTo(this); }); // Jeder Zeile Code + Index geben $('tr.answers-list', thisTable).each(function(i) { $(this).attr('data-index', i); // Bei Array-by-column ist value meist der stabile Teilfragecode var code = $('input[type="radio"]', this).first().val(); $(this).attr('data-code', code); }); function saveOrder() { var orderArr = []; $('tr.answers-list', thisTable).each(function() { orderArr.push($(this).attr('data-code')); }); hiddenInput.val(orderArr.join('|')).trigger('change'); } function applySavedOrder(savedOrder) { var orderArr = savedOrder.split('|'); $(orderArr).each(function(i, code) { var row = $('tr.answers-list[data-code="' + code + '"]', thisTable); if (row.length) { thisTbody.append(row); } }); } // Random rows oder gespeicherte Reihenfolge anwenden var savedOrder = $.trim(hiddenInput.val()); if (savedOrder) { applySavedOrder(savedOrder); } else if (randomize) { var rowsArr = []; $('tr.answers-list', thisTable).each(function(i) { rowsArr.push(i); }); shuffleArray(rowsArr); $(rowsArr).each(function(i) { thisTbody.append($('tr[data-index="' + this + '"]', thisTable)); }); saveOrder(); } else { saveOrder(); } // Prevent clicking twice in the same row function updateRowLocks() { $('input[type="radio"]', thisQuestion).prop('disabled', false); $('input[type="radio"]:checked', thisQuestion).each(function(i) { var thisRow = $(this).closest('tr.answers-list'); $('input[type="radio"]', thisRow).not(this).prop('disabled', true); }); } updateRowLocks(); $('input[type="radio"]', thisQuestion) .off('click.maxdiff') .on('click.maxdiff', function() { updateRowLocks(); }); // Fix up the row classes $('tr.answers-list', thisTable).removeClass('array1 array2').each(function(i) { $(this).addClass('array' + (2 - (i % 2))); }); } 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).ready(function() { maxDiff({QID}, true); }); </script> <style type="text/css">.ls-answers tbody .answertext { text-align: center; } </style>
<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 "maxDiff2order" question var answerCodesString = "{maxDiff2order.NAOK}"; var answerCodes = answerCodesString.split('|'); //var answerCodes = '{maxDiff2order}'.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.
Please Log in to join the conversation.
Vielleicht lädst Du den aktuell "kaputten" Fragebogen als LSS auch hoch. Sonst lassen sich Fehler schwerlich finden, die vielleicht aus einem Zusammenspiel von Veränderungen entstehen.
Please Log in to join the conversation.
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ 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; } // Identify some elements var randomize=true; var qID='{QID}'; var thisQuestion = $('#question'+qID); var thisTable = $('table.subquestion-list:eq(0)', thisQuestion); // Die folgende Textfrage wird angesprochen var hiddenQuestion = $(thisQuestion).nextAll('.text-short:eq(0)'); // Assign a new question class $(thisQuestion).addClass('max-diff-array'); // Move the columns $('thead tr:eq(0)', thisTable).prepend($('thead tr:eq(0) th:eq(1)', thisTable)); $('tr.answers-list', thisTable).each(function(i){ $('td.answer-item:eq(0)', this).prependTo(this); }); // Random rows if(randomize) { var rowsArr=; $('tr.answers-list', thisTable).each(function(i){ $(this).attr('data-index', i); rowsArr.push(i); }); shuffleArray(rowsArr); $(rowsArr).each(function(i){ $('tbody', thisTable).append($('tr[data-index="'+this+'"]', thisTable)); }); // Das erzeugte Array wird in die Textfrage geschrieben. $('input:text', hiddenQuestion).val(rowsArr); } // Prevent clicking twice in the same row $('input[type="radio"]', thisQuestion).on('click', function () { $('input[type="radio"]', thisQuestion).prop('disabled', false); $('input[type="radio"]:checked', thisQuestion).each(function(i) { var thisRow = $(this).closest('tr.answers-list'); $('input[type="radio"]', thisRow).not(this).prop('disabled', true); }); }); // Fix up the row classes var rowClass = 1; $('tr.answers-list', thisTable).each(function(i) { $(this).addClass('array'+(2-(i%2))); }); }); </script> <style type="text/css">.ls-answers tbody .answertext { text-align: center; } </style>[/i][/i]
<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.