Welcome, Guest
Username: Password: Remember me

TOPIC: random order of answer categories, except for...

Re:random order of answer categories, except for... 3 years 5 months ago #57451

  • ftrifoglio
  • ftrifoglio's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 20
  • Karma: 1
I found the issue. In the bluengrey template none class is specified for the td containing the answers.
So I just put the ".answer" away from the script and it works.
The administrator has disabled public write access.

Re:random order of answer categories, except for... 3 years 5 months ago #57460

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4069
  • Thank you received: 746
  • Karma: 341
All of my workarounds use the default template and may need to be tweaked for other templates.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re:random order of answer categories, except for... 2 years 1 week ago #83650

Hi There I'm trying to randomise the answers except for the first answer of 8 answers.

I have seen the workaround for keeping the last answer static but I cant even get this to work, possibly the version I am using 1.87, in which case I really should upgrade.

Trying to work out what changes to make to the code to keep the first answer in place? put -7 after ansCount?

"/ Place the last answer created at the end of the list
$( 'input#answer' + sID + 'X' + gID + 'X' + qID + ansCount-7...etc"?

but as cant get the sample to work I am stuck any suggestions?

www.ap.urscorp.com/Consultation/index.php?sid=26127&lang=en

I have attached my question and a demo survey
Attachments:
The administrator has disabled public write access.

Re:random order of answer categories, except for... 2 years 1 week ago #83679

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4069
  • Thank you received: 746
  • Karma: 341
Try this (replacing "QQ" with the question ID):
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		// Function to allow randomization of all answers except the first one in multiple-options and list-radio questions
		function partRand(qID) { 
 
			// Find the survey and group IDs
			if($( 'input#fieldnames' ).length != 0) {
				var fieldNames = $( 'input#fieldnames' ).attr('value');
				var tmp = fieldNames.split('X');
				var sID = tmp[0];
				var gID = tmp[1];
			}
 
			// Place the first answer created at the beginning of the list
			$('input#answer' + sID + 'X' + gID + 'X' + qID + 1 + '' ).parent().prependTo($( '#question' + qID + ' td.answer ul' ));
 
		}
 
		// Call the function with the question ID
		partRand(QQ);
 
	});
 
</script>
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
The following user(s) said Thank You: Schroder101

Re:random order of answer categories, except for... 2 years 1 week ago #83693

works like a charm, thanks so much!
The administrator has disabled public write access.

Re: random order of answer categories, except for... 2 years 6 days ago #83721

Ok I realized I also need another tweak

in another question with 13 answers i need to keep the first two answers and the last answer static and also retain the 'other' option at the very end.

I edited the code just by adding another couple of lines see attached which sort of worked however I'm not sure how to make 'other' option show up last.

any suggestions?
Attachments:
The administrator has disabled public write access.

Re: random order of answer categories, except for... 2 years 5 days ago #83750

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4069
  • Thank you received: 746
  • Karma: 341
Try this to place the "Other" at the end of the list:
$( 'input#answer' + sID + 'X' + gID + 'X' + qID + 'othercbox' ).parent().appendTo($( '#question' + qID + ' td.answer ul' ));
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
The following user(s) said Thank You: Schroder101

Re: random order of answer categories, except for... 2 years 5 days ago #83771

  • geejay76
  • geejay76's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
All of these tips are proving very helpful - thanks!

I've been unsuccessfully trying to create a randomisation for a list of 10 attributes with option 10 being a "none of the above" option. In addition to these 10 attributes I also want to include an other option.

I am trying to set up the order of the list so that the first 9 attributes are randomised, then the Other option is displayed, then None at the bottom.

At the moment I can get the randomisation working, but I can;t seem to get the None to lock at the bottom.

Any help would be much appreciated.
The administrator has disabled public write access.

Re: random order of answer categories, except for... 2 years 5 days ago #83772

Ok that worked thanks!
The administrator has disabled public write access.

Re: random order of answer categories, except for... 2 years 5 days ago #83773

Just replace this line in the code posted above - replacing the bit were it calls the first answer only and make sure the other option is activated should work

// Place answer no 10 last below 'other'
$('input#answer' + sID + 'X' + gID + 'X' + qID + 10 + '' ).parent().appendTo($( '#question' + qID + ' td.answer ul' ));
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.178 seconds
Donation Image