Individual Grouping

Certain requirements in terms of the grouping for behavioral research experiments are not covered by the grouping mechanisms mentioned here. For some experiments it might be necessary to have a real random grouping, where participants are guaranteed to compete with a different participant every round and not play with the same partner twice. Another situation might be a different, pregenerated grouping for individual stepgroups.

You can create your own grouping mechanisms by using the grouping API functionalities. Below you can see an example on how to use these. Assuming that a pregenerated grouping with two participants each was used for the first part of the experiment, we would like to have ten participants per group for the rest of the experiment. Participants from the same group stay together in the same group.

$groups = $groupApi->getGroupLabels();

$participantArray = array();
foreach ($groups as $group)
{
    $groupMembers = $groupApi->getGroupMemberLabels($group);

    foreach($groupMembers as $groupMember)
    {
        if (count($participantArray) < 10)
        {
            $participantArray[] = $groupMember;
        }
        else
        {
            $emptyGroups = $groupApi->getEmptyGroupLabels();
            $groupApi->addGroupMembers($participantArray, $emptyGroups[0]);
            $participantArray = array();
        }
    }

    $groupApi->removeGroupMembers($groupMembers, $group);
}