Check out the LimeSurvey source code on GitHub!
Welcome, Guest
Username: Password:

TOPIC: Partially Randomized Answers

Partially Randomized Answers 5 years 9 months ago #57550

  • AndrejL
  • AndrejL's Avatar
  • Offline
  • Junior Lime
  • Posts: 39
  • Karma: 1
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: 5 years 9 months ago by AndrejL.
The administrator has disabled public write access.

Partially Randomized Answers 5 years 9 months ago #57551

  • AndrejL
  • AndrejL's Avatar
  • Offline
  • Junior Lime
  • Posts: 39
  • Karma: 1
For example, this is what I get if i put last 3 answers in last position.

picture
Last Edit: 5 years 9 months ago by AndrejL.
The administrator has disabled public write access.

Partially Randomized Answers 5 years 9 months ago #57555

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • Moderator Lime
  • Posts: 9555
  • Thank you received: 1373
  • Karma: 389
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 (Need support ?).
A bug not reported is a bug not corrected. | 2.61lts version improved | Need plugins for LimeSurvey ?
The administrator has disabled public write access.

Partially Randomized Answers 5 years 9 months ago #57558

  • AndrejL
  • AndrejL's Avatar
  • Offline
  • Junior Lime
  • Posts: 39
  • Karma: 1
I did. It doesn't do the trick.

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

Andrej
The administrator has disabled public write access.

Partially Randomized Answers 5 years 9 months ago #57560

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • Moderator Lime
  • Posts: 9555
  • Thank you received: 1373
  • Karma: 389
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 (Need support ?).
A bug not reported is a bug not corrected. | 2.61lts version improved | Need plugins for LimeSurvey ?
The administrator has disabled public write access.

Partially Randomized Answers 5 years 9 months ago #57564

  • AndrejL
  • AndrejL's Avatar
  • Offline
  • Junior Lime
  • Posts: 39
  • Karma: 1
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
The administrator has disabled public write access.

Partially Randomized Answers 5 years 9 months ago #57589

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • Moderator Lime
  • Posts: 9555
  • Thank you received: 1373
  • Karma: 389
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 (Need support ?).
A bug not reported is a bug not corrected. | 2.61lts version improved | Need plugins for LimeSurvey ?
The administrator has disabled public write access.
Time to create page: 0.440 seconds
Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form