Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:

THEMA: Randomize order BUT keeping 2 elements always together?

Randomize order BUT keeping 2 elements always together? 1 Jahr 11 Monate her #87428

Got an interesting problem here and wondering if I can implement it without using complex JS.

If I have a multiple choice question with 5 choices and I want to randomize them, BUT I want to keep elements 4 and 5 always together... what are my options?

So, for example (two possible randomizations):
3
1
4
5
2

or...

2
4
5
1
3


Subsequent questions should maintain this randomization order as well, which is perhaps a separate issue.
I'm a call centre and market research technology consultant, lead/sample provider, and panel broker.

I'm also the co-founder and former IT Director of Winning Research Ltd. - LimeSurvey helped the company become a multi-million dollar company within just a few years!
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Randomize order BUT keeping 2 elements always together? 1 Jahr 11 Monate her #87687

  • paulfiner
  • paulfiners Avatar
  • OFFLINE
  • Expert Lime
  • Beiträge: 92
  • Dank erhalten: 1
  • Karma: 1
Did you ever find a solution to this?

I need something similar to this ie. I need to randomise the answers apart from the last 2 which, in my case, are 'Don't know' and 'None of these'.

Any javascript solution?
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Randomize order BUT keeping 2 elements always together? 1 Jahr 11 Monate her #87843

  • StuartMark0
  • StuartMark0s Avatar
  • OFFLINE
  • Junior Lime
  • Beiträge: 26
  • Karma: 0
Have you guys figured it out yet?
I have similar situation wherein I would like to anchor the last statement.

Cheers,
Mark.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Randomize order BUT keeping 2 elements always together? 1 Jahr 11 Monate her #87844

  • paulfiner
  • paulfiners Avatar
  • OFFLINE
  • Expert Lime
  • Beiträge: 92
  • Dank erhalten: 1
  • Karma: 1
I had problems getting the workarounds to work but I managed to get it work using my limited knowledge of Javascript and various Google searches.

Using the code below you just need to change the codes in the variable ansCodesList to match the codes you want to randomise and then add any others that you want to remain fixed, two in my case.
This works on a multi-choice type question but not sure about a radio list type.
<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
 
		var ansCodesList = [1,2,3,4,5,6];
 
		ansCodesList.sort(function() {return 0.5 - Math.random()})
 
		ansCodesList.push(7);
		ansCodesList.push(8);
 
		// The multi-opt id
		var multiOptID = $('.multiple-opt').attr('id').split('question')[1];
 
		var answersParent = $('.multiple-opt li[id^="javatbd"]:eq(0)').parent();
 
		// Change the order of the multi-opt answers
		$(ansCodesList).each(function(i){
			$(answersParent).append($('.multiple-opt li[id$="'+multiOptID+this+'"]'))
		});
	});
</script>
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Moderatoren: ITEd
Ladezeit der Seite: 0.130 Sekunden
Donation Image