Have an idea?

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

Randomize a subset of attributes

For my ACBC survey I would like to randomize not all but only a subset of attributes. For example, if I have 6 attributes, I want the first 2 attributes to always be the same, and only the remaining 4 should be randomized. This is due to some sort of natural order of a few product features.

This should be the order in BYO, Screening and Choice Tournament sections:

Attribute 1 (fixed)
Attribute 2 (fixed)
Attribute 3 (randomized)
Attribute 4 (randomized)
Attribute 5 (randomized)
Attribute 6 (randomized)

How do I changed the code of the constructed list below to take this into account?

ADD (attributes)
RANDOMIZE()


Thank you!
asked Jan 16 by danny Bronze (755 points)

1 Answer

+1 vote
Just add parameters to your Randomize instruction.

ADD (attributes)
RANDOMIZE(3,6)

This will only randomize members 3-6 of the list.
answered Jan 16 by Jay Rutherford Gold (39,625 points)
That was quick!
Thank you so much Jay.

Do you possibly also have an idea of how to randomize the attribute descriptions on a text-type question? Right before the BYO section I added a page with text that describes each of the attributes. It would be of course great to have the very same randomized order there as in the other sections. The only problem is that the descriptions are all in one place, as text. What could be a workaround for this? I guess I somehow have to split one "Text" component in a page into 6 Text components and then somehow address this in the code?
So you want the description text to be randomized in the same order as the randomized list we just worked on?  You could split the text into 6 different text questions on the same page and then randomize those questions on a page.  I'm sure there are a number of ways you could do this, but my suggestion is using lists. Here are the steps I would suggest:

- For this example, I will refer to the previous list we created as 'PreviousList' (I know real original, lol)
- Create a list, lets say 'TextList'.
- Cut each of your 6 text components and paste each as an item in your list. Make sure the order of the items is the same order as your Parent List from 'PreviousList'
- Create a constructed list using 'TextList' as the parent list.  Let's call this 'TextListRandom'.
- Use this code: MIRROR (PreviousList)
- Since both lists have 6 items, this will create your constructed list in the same order as 'PreviousList'.
- Now on your text question where we took all the text from you can add this:
<p>[%ListLabel (TextListRandom,1)%]</p>
<p>[%ListLabel (TextListRandom,2)%]</p>
<p>[%ListLabel (TextListRandom,3)%]</p>
<p>[%ListLabel (TextListRandom,4)%]</p>
<p>[%ListLabel (TextListRandom,5)%]</p>
<p>[%ListLabel (TextListRandom,6)%]</p>

Now your text screen will show each item in it's own paragraph in the same order as the constructed list you are using later.  Hope this makes sense, but it should get you what you are looking for.  Let me know how it goes.
VERY NEAT! Thank you Jay. I followed your instruction and it works perfectly fine!!! It's amazing that with Sawtooth it is possible to customize basically anything!!
Great!  Glad you got it working as you needed.  Yes, Sawtooth is a great base and you truly can do a lot to customize for just about any scenario.  There are some really cool things you can do if you are good with javascript.  However, always remember that there are multiple ways to accomplish things and many times it can be done using lists and some Sawtooth Script.  I use lists for a lot of text type solutions, and the Mirror function has become a staple in my bag of tricks.
...