Have an idea?

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

Show the list by group

Dear All,

I have a select question (Multiple choice) as below:

Group A
1. A1
2. A2
3. A3
Group B
4. B1
5. B2
6. B3
Group C
7. C1
8. C2
9. C3
Other Group
10. Other1 (Please specify)
11. Other2 (Please specify)
12. Other3 (Please specify)

I want the system show like this format. Is it possible? Please give detail to me.

Regards,
Saroeun
asked Dec 2, 2016 by Saroeun Bronze (1,095 points)
retagged Dec 2, 2016 by Walter Williams

1 Answer

+1 vote
 
Best answer
Saroeun, pop this JavaScript into the HTML <head> Tag of your select question ...
<script type="text/javascript">
$(document).ready(function(){

    $('#Q1_div > .question_body .response_column > div:nth-child(1)')
        .before('<div><b>Group A</b></div>');

    $('#Q1_div > .question_body .response_column > div:nth-child(5)')
        .before('<div><b>Group B</b></div>');

    $('#Q1_div > .question_body .response_column > div:nth-child(9)')
        .before('<div><b>Group C</b></div>');

})
</script>

I have assumed your question to be Q1. Change the "#Q1_div" to whatever your question number is.
answered Dec 2, 2016 by Paul Moon Platinum (57,565 points)
selected Dec 6, 2016 by Saroeun
Sorry Zachary. Just noticed you provided a randomisation solution.

Now Saroeun has multiple options which beats none.

Great stuff again mate.
Thanks Paul, but this construction only random within category.  But i want to randomize by category and within category. It is very important to me, could you help me?
OK, didn't realise you also wanted to randomise the groups also.

Create a parent list called OrderList ...
1-A
2-B
3-C

Now create a constructed list called OrderConlist ...
ADD(OrderList)
Randomize()

Now edit the constructed list called GroupAllConList as such ...
Begin Unverified Perl
 
 ADD("Group".LISTLABEL("OrderConList",1)."ConList",1);
 ADD("Group".LISTLABEL("OrderConList",2)."ConList",2);
 ADD("Group".LISTLABEL("OrderConList",3)."ConList",3);
 ADD("GroupList",9,12);
 
End Unverified 

In Zachary's v8 script, you need to change the following ...

1/ Change "Group A" to "<b>Group [%ListLabel(OrderConList,1)%]</b>"
2/ Change "Group B" to "<b>Group [%ListLabel(OrderConList,2)%]</b>"
3/ Change "Group C" to "<b>Group [%ListLabel(OrderConList,3)%]</b>"

Just tested it out in v8 and works a treat!
Yes, Thanks. What about filter of each group, are they random follow their group right?
Each group will follow the sub-group heading.

If Group A appears 2nd, the group A codes will appear under the Group A sub-group heading and the same goes for all other groups.

The last group (other codes) will always appear last.
...