Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Randomize Constructed List for each question

I´m using sawtooth 9.3

I have several questions that use the same constructed list, but for each question I want a different order.  I´m already using the function randomize() in my constructed list but it show the same order for every question.

There is a different way to do it, without creating multiple constructed list for each question?
asked Mar 15, 2017 by anonymous
Creating a constructed list for each question might be the simplest option.  Alternatively, JavaScript could be used to randomize the responses at runtime, but you would not be able to see the order of the responses in the data.  I can help create this code, but I would want to know what question types you are using that need randomization.
The question type is Grid and I´m using the library Categorization. I would like to try a different option because I have about 50 questions. How is an example using JavaScript?

1 Answer

0 votes
Best answer
Cool, I'm glad to see the Categorization question getting some traction with users.  At the end of the code in the footer, before the last two lines ("})" and "</script>"), you can add this code to randomize the response options:

    // Randomize items
    if ($('#[% QuestionName() %]_defaultSortableContainer .sortableItem').length == rowsList.length) {
        $('#[% QuestionName() %]_defaultSortableContainer .sortableItem').sort(function(){
            return Math.random() > 0.5;
            $('#[% QuestionName() %]_defaultSortableContainer .sortable').append($(this));
answered Mar 15, 2017 by Zachary Platinum Sawtooth Software, Inc. (100,575 points)