Partially Randomized Answers Array

More
2 years 11 months ago - 2 years 11 months ago #115583 by jelo
jelo created the topic: Partially Randomized Answers Array
If you want to randomize not all items of an array, but keep certain item on there position.
Is there a workaround possible? Often there are groups of items which should be randomized as block as well. The workaround list in the manual seems to more into one column answers.

BTW: The manual states Array and Other option.
manual.limesurvey.org/Question_type_-_Ar...Other.27_.28other.29
Is that the case? I haven't seen this option (in the uptodate versions)?


Thanks in advance.
Last Edit: 2 years 11 months ago by jelo. Reason: Add Lines

Please Log in to join the conversation.

More
2 years 11 months ago #115587 by tpartner
tpartner replied the topic: Partially Randomized Answers Array

If you want to randomize not all items of an array, but keep certain item on there position.

Adding a script like this to the question source will "fix" the item with sub-question code "A1" in the last position.
<script type="text/javascript" charset="utf-8">	
	$(document).ready(function() {
 
		// The sub-question code to place in the last position
		var fixedCode = 'A1';
 
		// Identify this question
		var q1ID = {QID};
		var thisQuestion = $('#question'+q1ID);
 
		// Move the "fixed" row to the end
		$('table.subquestions-list tbody', thisQuestion).append($('tr[id$="X'+q1ID+fixedCode+'"]'));
 
    });
</script>

...Is that the case? I haven't seen this option (in the uptodate versions)?

No, that is an error.


.

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
2 years 11 months ago #115659 by jelo
jelo replied the topic: Partially Randomized Answers Array
Thanks Tony for your feedback.

I remember a few sideeffects when using this kind of workarounds with certain templates.
Isn't there a problem with the colors, when rows are in different colors?
The e.g. default template, right?

Please Log in to join the conversation.

More
2 years 11 months ago #115661 by tpartner
tpartner replied the topic: Partially Randomized Answers Array
Try this:

<script type="text/javascript" charset="utf-8">	
	$(document).ready(function() {
 
		// The sub-question code to place in the last position
		var fixedCode = 'A1';
 
		// Identify this question
		var q1ID = {QID};
		var thisQuestion = $('#question'+q1ID);
 
		// Move the "fixed" row to the end
		$('table.subquestions-list tbody', thisQuestion).append($('tr[id$="X'+q1ID+fixedCode+'"]'));
 
		// Fix up the array row background colours
		$('tr.answers-list', thisQuestion).each(function(i){
			$(this).removeClass('array1 array2').addClass('array'+(2-(i%2)));
		});
 
    });
</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
2 years 11 months ago #115665 by jelo
jelo replied the topic: Partially Randomized Answers Array
Thanks Tony,

do you have a big library of workaround? Or are doing it all out of your head.
And that early in the morning in your timezone, right?

Perhaps a Tony Advisor should be added to the HTML Editor inside Limesurvey.

If I get it right, this workaround for arrays is not in the manual/wiki.

Thanks.

Please Log in to join the conversation.

More
2 years 11 months ago #115667 by tpartner
tpartner replied the topic: Partially Randomized Answers Array

do you have a big library of workaround? Or are doing it all out of your head.

I do a little searching in my files for previous workarounds but most are from scratch.

If I get it right, this workaround for arrays is not in the manual/wiki.

Now it is - manual.limesurvey.org/Workarounds:_Manip...rs_-_Array_questions


.

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
2 years 11 months ago #115701 by Mazi
Mazi replied the topic: Partially Randomized Answers Array
Thanks, Tony!


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.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!