oTree Forum >

Can I clear Chat?

#1 by help_wanted

Hi all,

I have a problem with Chat.

I want to match players differently twice. (At the end, there will be different tasks for each match)
(For example, at first Group1=(P1, P2), Group2 =(P3, P4) 
and in the second, Group1=(P3, P2), Group2 =(P1, P4) )

And for every match, I want to make players to chat each other.
However, I've found that the chat from the previous pages, with a channel remains even after the start of new page. I wish I can clear chat from the previous chat.

More specifically, with my code, (you can see it below)
I with Chat in "MyPage" will be clear out when it goes to "Page1"


(Also, I do not want to simply repeat the rounds, because I do not want the data size be super big)

 The followings are my code and I also attached the screenshot:
 
 I would appreciate any help!
 

class C(BaseConstants):
    NAME_IN_URL = 'role'
    PLAYERS_PER_GROUP = 2
    NUM_ROUNDS = 1
    PRINCIPAL_ROLE = 'Principal'
    AGENT_ROLE = 'Agent'


class Subsession(BaseSubsession):
    pass


class Group(BaseGroup):
    pass


class Player(BasePlayer):
    pass


def chat_nickname(player):
    group = player.group
    return 'Group {} player {}'.format(group.id_in_subsession, player.id_in_group)


def chat_channel(player):
    group = player.group

    return 'Group {}'.format(group.id_in_subsession)



class ShuffleWaitPage0(WaitPage):
    wait_for_all_groups = True

    @staticmethod
    def after_all_players_arrive(subsession):
        subsession.group_randomly()


class MyPage(Page):

    @staticmethod
    def vars_for_template(player):
        return dict(
            channel=chat_channel(player)
        )


class ShuffleWaitPage(WaitPage):
    wait_for_all_groups = True

    @staticmethod
    def after_all_players_arrive(subsession):
        subsession.group_randomly()



class Page1(Page):
    @staticmethod
    def vars_for_template(player):
        return dict(
            channel=chat_channel(player)
        )


class ResultsWaitPage(WaitPage):
    pass


class Results(Page):
    pass


page_sequence = [ShuffleWaitPage0, MyPage, ShuffleWaitPage, Page1, Results]

Write a reply

Set forum username