Check out the LimeSurvey source code on GitHub!

Partially Randomized Answers

More
6 years 15 hours ago - 6 years 15 hours ago #57550 by AndrejL
Hi!

I want to use this topic to discover how I can randomize all but last few answers. It is common that in the end of the question we have some "DK, "none", "other" answers we do not want to randomize with others.

With this workaround
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() { 
 
		// Function to allow randomization of all answers except the last one in Multiple options and List/radio questions
		function partRand(sID, gID, qID) { 
 
			// Find the number of answers
			var ansCount = ""
			$( "div#question" + qID + " td li" ).each(function(i) {
				ansCount = (i + 1);
 
			});				
 
			$( "input#answer" + sID + "X" + gID + "X" + qID + "1" ).parent().appendTo($( "#question" + qID + " td ul" ));
			$( "input#answer" + sID + "X" + gID + "X" + qID + "2" ).parent().appendTo($( "#question" + qID + " td ul" ));
			$( "input#answer" + sID + "X" + gID + "X" + qID + "3" ).parent().appendTo($( "#question" + qID + " td ul" ));			
		}
 
 
 
		// Call the function with the SID, GID and QID
		partRand(sID, gID, qID);
 
	});
 
</script>

we can (with some adjustments) easily randomize all but last few (1,2,3 ...) answers.

But what I can't do is to use this script with other option included. When I use the script it puts answer even after other option. but I want other to be the last answer.

How can I do this?

Thanks,

Andrej
Last Edit: 6 years 15 hours ago by AndrejL.

Please Log in to join the conversation.

More
6 years 15 hours ago - 6 years 15 hours ago #57551 by AndrejL
For example, this is what I get if i put last 3 answers in last position.

picture
Last Edit: 6 years 15 hours ago by AndrejL.

Please Log in to join the conversation.

More
6 years 15 hours ago #57555 by DenisChenu
Trye with something like that
$( "input#answer" + sID + "X" + gID + "X" + qID + "other" ).parent().appendTo($( "#question" + qID + " td ul" ));

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).

Please Log in to join the conversation.

More
6 years 14 hours ago #57558 by AndrejL
I did. It doesn't do the trick.

No luck with "-oth-" or "Other (-oth-)" also.

Andrej

Please Log in to join the conversation.

More
6 years 14 hours ago #57560 by DenisChenu

AndrejL wrote: I did. It doesn't do the trick.

No luck with "-oth-" or "Other (-oth-)" also.

Andrej


Oups, i don't use exactly this method, try:
$( "li#javatbd" + sID + "X" + gID + "X" + qID + "other" ).appendTo($( "#question" + qID + " ul" ));

And, you can have a look at jquery documentation and at the source code (eventually with firebug) to make your own manipulation :)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).

Please Log in to join the conversation.

More
6 years 13 hours ago #57564 by AndrejL
Hi!

Excellent, that works, thanks.

Sorry for all the questions that look simple to you but I never used JS before yesterday. I'm currently have 1-day experience. Not an expert to say the least.

Andrej

Please Log in to join the conversation.

More
5 years 11 months ago #57589 by DenisChenu

AndrejL wrote: Sorry for all the questions that look simple to you but I never used JS before yesterday. I'm currently have 1-day experience. Not an expert to say the least.

Ho, not a problem,

I just give this advice to offer you to be quickly ;)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form