Welcome to the LimeSurvey Community Forum

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

Randomize the order of some items in array with last X options fixed

More
1 day 10 hours ago #272506 by eperezpena
Hello This script allows you to randomly rotate the elements of an array while fixing the order of the last X elements (typically None, Don't Know, or No Answer).1) Create an array, set random order = TRUE2) In SOURCE MODE. Insert the following script.
Code:
[color=#000000]<script type='text/javascript'>[/color]
[color=#000000]$(document).ready(function() {[/color]
[color=#000000]var move_codes = [/color][color=#000000]["6", "7", "8", "9","96", "97", "99"];[/color]
[color=#000000]var baseId = "javatbd{SGQ}";[/color]
[color=#000000]var questionSelector = "#question{QID} .answers-list .answer-item:last-child";[/color]

[color=#000000]move_codes.forEach(function(code) {[/color]
[color=#000000]var move_element = baseId + code;[/color]
[color=#000000]$("#" + move_element).insertAfter(questionSelector);[/color]
[color=#000000]});[/color]
[color=#000000]});[/color]
modifying ONLY this"6", "7", "8", "9", "96", "97", "99"Which are the items that remain unrotated tested on LimeSurvey Community Edition Version 6.15.10+250901 and  LimeSurvey CE Version 3.17.5+190604

 

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose