Group randomization for a pick, group and rank question | XM Community
Skip to main content
Hello together. I have a problem with a pick, group and rank question. How can I randomly arrange the groups? The menu "Answer Randomization" unfortunately does not work. :-(
Hello @Ingo , This can be a good feature request.
Hello @Shashi, Thanks for your feedback, but that doesn't help me right now. Does anyone have a solution to my problem?
Hello @Ingo , For randomly arrange group in PGR question, paste the below in the js(OnReady) of the PGR question: var that=this.questionId; 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; } var n = jQuery("#"+that+" .Group").length; var s=[]; for(var i=0;i<n;i++){ s.push(i); } s=shuffle(s); console.log(s); var c=0; for(var i=0;i<n;i++){ jQuery("#"+that+" .Group:eq("+s[i]+")").insertAfter("#"+that+" .Group:eq("+c+")"); c++; }
Thank you very much, that seems to be working. :) Have a nice weekend.