Have an idea?

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

Same weight in Block randomization

Hey all,

I include the following code in a constructed list based on my 10 blocks.

Begin Unverified Perl
my$RandNum=SYSRAND(1,2);
    if($RandNum==1)
    {
    my$RandNum=SYSRAND(1,2);
    if($RandNum==1)
    {
        ADD("BlockList",1,3);
        RANDOMIZE();
        ADD("BlockList",5);
    }
    else
    {
        ADD("BlockList",1,2);
        ADD("BlockList",4);
        RANDOMIZE();
        ADD("BlockList",5);
    }}
    else
    {
    my$RandNum=SYSRAND(1,2);
    if($RandNum==1)
    {
        ADD("BlockList",6,8);
        RANDOMIZE();
        ADD("BlockList",10);
    }
    else
    {
        ADD("BlockList",6,7);
        ADD("BlockList",9);
        RANDOMIZE();
        ADD("BlockList",10);
    }}
End Unverified

So it works everything fine, only the amount of participants in each group differs much.

Group 1 conduct following blocks: 1,2,3,5
Group 2 conduct following blocks: 1,2,4,5
Group 3 conduct following blocks: 6,7,8,10
Group 4 conduct following blocks: 6,7,9,10

This works so far, so good,

But I need the same amount of participants in each group.

Anyone can help?

I am thankful for every answer!
asked Jan 17 by Honeybadger Bronze (890 points)

1 Answer

0 votes
You may want to consider using a quota question with the 'least fill' option selected.  Set up 4 cells in the quota to always qualify set with the same cell limit.  Then select the 'least fill' option for checking for cell membership.  This will make sure they stay even.  You can then add the blocks for the 4 groups based on the value in the quota question.
answered Jan 17 by Jay Rutherford Platinum (50,145 points)
Thanks for the fast answer. Maybe you could help me with some coding stuff also.

I insert the following code:

[% Begin Unverified Perl
if(ACBC==SHOWN)
    {
        return(ACBCWINNERLABEL(ACBC,5));
    }
else
    {
        return((VWDLI1+VWDLI2)*0.5);
    }
End Unverified %]

But Survey always interrupts and i got 132 error in admin module.

Where is my mistake?
I assume that ACBC is the name of your exercise.  I don't know that you can call upon it that way.  if(SHOWN("ACBC")) would be the format for using the Shown script.  I'm not sure if you can call upon the name of the exercise or if it has to be a specific question name but you can give it a shot with the correct formatting.
Unfortunately it doesn't work...

System Error:
Bareword "ACBC" not allowed while "strict subs" in use at (eval 145) line 1, line 22. Bareword "VWDLI1" not allowed while "strict subs" in use at (eval 145) line 7, line 22. Bareword "VWDLI2" not allowed while "strict subs" in use at (eval 145) line 7, line 22.

That is the error code, which I receive.
I would suggest posting a new thread for that problem and someone may be able to direct you better.
It works by standing alone.

I can return the ACBC Winning Price with this expression:
[% ACBCWINNERLABEL(ACBC,5)%]

I can return my VWD Price with this expression:
[% (VWDLI1+VWDLI2)*0.5 %]

But I need an if_else logic, because only one price should be shown.
Everyone will see VWD Section but only a part will see ACBC so I want to show ACBC Price if ACBC is shown and VWD if ACBC is not shown.

Any solutions?
...