Welcome to the LimeSurvey Community Forum

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

Partially Randomized Answers Array

  • jelo
  • jelo's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
9 years 4 months ago - 9 years 4 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.
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.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Last edit: 9 years 4 months ago by jelo. Reason: Add Lines
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 4 months ago #115587 by tpartner
Replied by tpartner on 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.
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.
  • jelo
  • jelo's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
9 years 4 months ago #115659 by jelo
Replied by jelo on 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?

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 4 months ago #115661 by tpartner
Replied by tpartner on topic Partially Randomized Answers Array
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.
  • jelo
  • jelo's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
9 years 4 months ago #115665 by jelo
Replied by jelo on 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.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 4 months ago #115667 by tpartner
Replied by tpartner on 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.
The topic has been locked.
  • Mazi
  • Mazi's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
9 years 4 months ago #115701 by Mazi
Replied by Mazi on topic Partially Randomized Answers Array
Thanks, Tony!

Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose