Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Randomisierung bei Mehrfachangaben

More
18 hours 33 minutes ago #272892 by agostini
Bitte helfen Sie uns, Ihnen zu helfen und füllen Sie folgende Felder aus:
Ihre LimeSurvey-Version: LimeSurvey Cloud   Version 6.15.20
Genutzte Designvorlage: fruity
==================
Ich habe eine Frage mit Mehrfachangaben

FRAGENTEXT (MEHRFACH)
--- Beginn Randomisierung
- item 1
- item 2
- item 3
--- Ende Randomisierung
- anderes (bitte angeben)
- weiß nicht

Die letzten zwei items sollen am Ende bleiben,. der Rest soll randomisiert vorgelegt werden. Ist so was möglich?

Danke!

Please Log in to join the conversation.

More
13 hours 4 minutes ago - 13 hours 3 minutes ago #272907 by Joffm
Hallo,
ja, das geht.
Dieses erste script ist leider nur die halbe Lösung, da hier die "Sonstige"-Option am Ende hinter KA stehen bleibt.
[url] www.limesurvey.org/manual/Workarounds:_M...meSurvey_version_3.x :[/url]

Aber Du kannst so vorgehen.
In einer vorherigen Gruppe kreierst Du eine Frage vom Typ "kurzer Text". Sie möge "randOrder" heißen.
Dort fügst Du (im Quellcode-Modus) dieses script ein
Code:
<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 array, hier Zahlen von 1 - 11
var arr = ;
for (var i = 1; i < 12; i++) {
arr.push(i);
}
arr = shuffle(arr);
arr.push('other');  
arr.push('12');
arr1=arr.join(',');
$('#question{QID} input[type="text"]').val(arr1);
$('#question{QID}').hide();
});
</script>


Hier gibt es also 11 "richtige" Items.
Diese werden zunächst durcheinandergewürfelt.
Dann wird für Code für "Sonstige" (other) und der Code für KA (12) angehängt.

In der eigentlichen Frage fügst Du dieses script ein
Code:
<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 "randOrder" question
    var answerCodes = '{randOrder}'.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>

Und voilá
Standard war alphabetisch.
 

Beachte: Diese Frage wird nun nicht mit der Einstellung "Zufällige Reihenfolge" randomisiert.

Joffm
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 13 hours 3 minutes ago by Joffm.

Please Log in to join the conversation.

Moderators: holchJoffmtpartner

Lime-years ahead

Online-surveys for every purse and purpose