Welcome, Guest
Username: Password: Remember me

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

random order of answer categories, except for... 4 years 4 months ago #43381

  • sdaza
  • sdaza's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 3
  • Karma: 0
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
The administrator has disabled public write access.

Re:random order of answer categories, except for... 4 years 4 months ago #43506

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5325
  • Thank you received: 296
  • Karma: 249
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)limesurvey.org'"
The administrator has disabled public write access.

Re:random order of answer categories, except for... 4 years 4 months ago #43521

  • sdaza
  • sdaza's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 3
  • Karma: 0
Okey, but i am talking about categories, not questions.
The administrator has disabled public write access.

Re:random order of answer categories, except for... 4 years 4 months ago #43533

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5325
  • Thank you received: 296
  • Karma: 249
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)limesurvey.org'"
The administrator has disabled public write access.

Re:random order of answer categories, except for... 4 years 4 months ago #43567

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4260
  • Thank you received: 801
  • Karma: 367
Try a modification of this workaround - docs.limesurvey.org/tiki-index.php?page=...List_radio_questions
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... 3 years 7 months ago #57377

  • ftrifoglio
  • ftrifoglio's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 20
  • Karma: 1
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();
}
The administrator has disabled public write access.

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

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4260
  • Thank you received: 801
  • Karma: 367
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.

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... 3 years 7 months ago #57395

  • ftrifoglio
  • ftrifoglio's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 20
  • Karma: 1
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: 3 years 7 months ago by ftrifoglio.
The administrator has disabled public write access.

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

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4260
  • Thank you received: 801
  • Karma: 367
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.

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... 3 years 7 months ago #57428

  • ftrifoglio
  • ftrifoglio's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 20
  • Karma: 1
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.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.147 seconds
Donation Image