jeudi 28 décembre 2017

creating a site for a medical study, need to seperate users into two groups randomly but evenly

I have this problem im trying to figure out. At first i thought about seperating users just by their user id by odds and evens. But my client says it needs to be a little bit more random then that.

if($user_id % 2 == 0) {

        $u->add_role( 'control' );
    }else{
        $u->add_role( 'study' );
    }

Users need to be placed into a control group, and a study group, out of 10 there need to be 5 in each, out of 100, 50 etc. But it apperantly something like 1 3 5 7 and 9 cant go in one while 2 4 6 8 10 go in the other. It should be more like

1 3 5 6 7 go in one 2 4 8 9 10 go in the other.

Im having trouble figuring out how to do that in a way that scales




Aucun commentaire:

Enregistrer un commentaire