Group#

class alfred3_interact.group.Group(matchmaker, **data)[source]#

Bases: object

The group object holds members and keeps track of their roles.

The group’s main task is providing access to the group members via their roles. Most importantly, the group offers the attributes me and you. Beyond that, you can use dot notation, using any member’s role like an attribute on the group. The group will return a GroupMember object for the member inhabiting that role.

Typically, you will not initialize a group object yourself, but receive it as a result of the matchmaking process via MatchMaker

See also

See GroupMember for information about member objects.

Examples

In this basic example, we access both group members through their roles and print their inputs on the last page:

import alfred3 as al
import alfred3_interact as ali

exp = al.Experiment()

@exp.setup
def setup(exp):
    spec = ali.SequentialSpec("a", "b", nslots=10, name="spec1")
    exp.plugins.mm = ali.MatchMaker(spec, exp=exp)

@exp.member
class Demo:

    def on_exp_access(self):
        self += al.TextEntry(leftlab="Enter some text", force_input=True, name="el1")

@exp.member
class Match(ali.WaitingPage):

    def wait_for(self):
        group = self.exp.plugins.mm.match()
        self.exp.plugins.group = group
        return True

@exp.member
class Success(al.Page):

    def on_first_show(self):
        group = self.exp.plugins.group
        role = group.me.role

        self += al.Text(f"Successfully matched to role: {role}")

        a = group.a
        b = group.b

        self += al.Text(f"Values of group member a: {a.values}")
        self += al.Text(f"Values of group member b: {b.values}")

Methods

active_members

A generator, iterating over all active members of the group.

active_other_members

A generator, iterating over all active members of the group except for me.

chat

Shortcut for creating a group chat.

deactivate

members

A generator, iterating over all members of the group.

other_members

A generator, iterating over the group members except for me.

takes_members

Indicates whether the group accepts members.

Attributes

finished

Indicates whether all group members have finished their experiment sessions.

full

Indicates whether all roles in the group are filled.

group_id

Unique group identification number.

me

GroupMember object for the own session.

nactive

Number of group members currently working on the experiment.

nfinished

Number of group members who have finished their experiment session.

shared_data

DEPRECATED shared group data dictionary.

spec_name

Name of the spec that was used to create this group.

you

GroupMember object for the other participant in a dyad (i.e.