Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Partially Randomized Answers Array

More
10 years 8 months ago - 10 years 8 months ago #115583 by jelo
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.
www.limesurvey.org/manual/Question_type_...Other.27_.28other.29
Is that the case? I haven't seen this option (in the uptodate versions)?


Thanks in advance.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Last edit: 10 years 8 months ago by jelo. Reason: Add Lines
The topic has been locked.
More
10 years 8 months ago #115587 by tpartner

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.
Code:
<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.
The topic has been locked.
More
10 years 8 months ago #115659 by jelo
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?

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
More
10 years 8 months ago #115661 by tpartner
Try this:

Code:
<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.
The topic has been locked.
More
10 years 8 months ago #115665 by jelo
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.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
More
10 years 8 months ago #115667 by tpartner

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 - www.limesurvey.org/manual/Workarounds:_M...rs_-_Array_questions


.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
10 years 8 months ago #115701 by Mazi
Thanks, Tony!

Best regards/Beste Grüße,
Dr. Marcel Minke
survey-consulting.com
offlinesurveys.com
Feel free to contact me by email for professional LimeSurvey support!
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose