Welcome, Guest
Username: Password: Remember me

TOPIC: Partially Randomized Answers

Partially Randomized Answers 3 years 5 months ago #57550

  • AndrejL
  • AndrejL's Avatar
  • OFFLINE
  • Bronze Donor
  • Posts: 35
  • 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: 3 years 5 months ago by AndrejL.
The administrator has disabled public write access.

Re: Partially Randomized Answers 3 years 5 months ago #57551

  • AndrejL
  • AndrejL's Avatar
  • OFFLINE
  • Bronze Donor
  • Posts: 35
  • Karma: 1
For example, this is what I get if i put last 3 answers in last position.

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

Re: Partially Randomized Answers 3 years 5 months ago #57555

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6252
  • Thank you received: 799
  • Karma: 239
Trye with something like that
$( "input#answer" + sID + "X" + gID + "X" + qID + "other" ).parent().appendTo($( "#question" + qID + " td ul" ));
The administrator has disabled public write access.

Re: Partially Randomized Answers 3 years 5 months ago #57558

  • AndrejL
  • AndrejL's Avatar
  • OFFLINE
  • Bronze Donor
  • Posts: 35
  • 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.

Re: Partially Randomized Answers 3 years 5 months ago #57560

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6252
  • Thank you received: 799
  • Karma: 239
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 :)
The administrator has disabled public write access.

Re: Partially Randomized Answers 3 years 5 months ago #57564

  • AndrejL
  • AndrejL's Avatar
  • OFFLINE
  • Bronze Donor
  • Posts: 35
  • 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.

Re: Partially Randomized Answers 3 years 5 months ago #57589

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6252
  • Thank you received: 799
  • Karma: 239
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 ;)
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.180 seconds
Donation Image