random order of answer categories, except for...

More
7 years 4 weeks ago #43381 by sdaza
sdaza created the topic: random order of answer categories, except for...
Hi everyone,
I have a question with 5 categories.

1
2
3
8
9

I want that only the first three categories to move randomly, and 8 and 8 keep fixed. I was trying to do it with:

<script type="text/javascript">

$(document).ready(function(){

$( 'input#answer25996X70X3749' ).parent().appendTo($( '#questionQQ td.answer ul' ));
});

</script>

But, it doesn't work. Even for the last choice (9).
Any ideas? Thank you in advance.

sdaza

Please Log in to join the conversation.

More
7 years 4 weeks ago #43506 by Mazi
Mazi replied the topic: random order of answer categories, except for...
There is no inbuild feature for this.

Maybe tpartner suggestion at this thread helps: www.limesurvey.org/en/support/forums/2-d...-randomization#43503


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

More
7 years 4 weeks ago #43521 by sdaza
sdaza replied the topic: random order of answer categories, except for...
Okey, but i am talking about categories, not questions.

Please Log in to join the conversation.

More
7 years 4 weeks ago #43533 by Mazi
Mazi replied the topic: random order of answer categories, except for...
Tony, any ideas?


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

More
7 years 4 weeks ago #43567 by tpartner
tpartner replied the topic: random order of answer categories, except for...

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

Please Log in to join the conversation.

More
6 years 4 months ago #57377 by ftrifoglio
ftrifoglio replied the topic: random order of answer categories, except for...
I would do the same thing of sdaza and the workaround suggested by tpartner it should be fit that, but I cannot make it work.

Actually I had a list radio question displayed in columns, so I thought that was the problem.
So I made a classic list radio question, just to try, but I get thesame outcome, that is I get the random order for all the answers.

This is what I did:

$filterxsshtml OFF
Option 'Other' NO
Random answer order YES
Sequential code for the answers (1, 2, ...)
The answer to keep at the end has the higher sequential code
This script code in the source of the question

File Attachment:

File Name: onloadcode.txt
File Size:1 KB


I've check the source of the demo survey of tpartner and I see, that in the head it call a js script with the same function and at the end of the source I found this script

// Call the Custom_On_Load function defined in the first question of the survey
// Only call if it's defined
if(typeof Custom_On_Load == 'function'){
Custom_On_Load();
}
Attachments:

Please Log in to join the conversation.

More
6 years 4 months ago #57387 by tpartner
tpartner replied the topic: random order of answer categories, except for...
You don't need to worry about the Custom_On_Load stuff anymore,

The script you found in the <head> is just a remote script for testing - it's commented out.

Use the script from the 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.answer li' ).each(function(i) {
				ansCount = (i + 1);
			});
 
			// Place the last answer created at the end of the list
			$( 'input#answer' + sID + 'X' + gID + 'X' + qID + ansCount + '' ).parent().appendTo($( '#question' + qID + ' td.answer ul' ));
 
		}
 
		// Call the function with the SID, GID and QID
		partRand(SSSSS, GG, QQ);
 
	});
 
</script>

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

Please Log in to join the conversation.

More
6 years 4 months ago - 6 years 4 months ago #57395 by ftrifoglio
ftrifoglio replied the topic: random order of answer categories, except for...
It still not work to me. I think I found the problem though.

I created a new survey, I just put the script in the question source and it worked. It's not even necessary to set the "show no answer" option, if the question is mandatory.

Then I tried to display the answers in columns but it's a mess. I tried to switch ul with li in the script, but it would be great if it were so simple.
Any chance to get a workaround for that?

Anyway it didn't work on my former survey because the template. For example it works with the default, but it doesn't with the bluengrey
Last Edit: 6 years 4 months ago by ftrifoglio.

Please Log in to join the conversation.

More
6 years 4 months ago #57418 by tpartner
tpartner replied the topic: random order of answer categories, except for...
Can you activate a sample survey for me to see?

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

Please Log in to join the conversation.

More
6 years 3 months ago #57428 by ftrifoglio
ftrifoglio replied the topic: random order of answer categories, except for...
I activated two surveys. They are the same except the template and the sID x gID x qID in the scripts.

(default) www.unipisurvey.org/lime9797/index.php?s...73&newtest=Y&lang=en
(bluengrey) www.unipisurvey.org/lime9797/index.php?s...33&newtest=Y&lang=en

The first one with the default template works fine.
The second one with the bluengrey template does not.

I added a second question with the column display. It would be great get the partially randomized function in that case too.

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now