from scl.pages import shared_vars from ._builtin import Page, WaitPage from anagram.models import Constants #class Information(Page): # def is_displayed(self): # return self.player.round_number == 1 # # def vars_for_template(self): # self.player.treatment = self.player.participant.vars['treatment'] # self.player.payment = self.player.participant.vars['payment'] # return { # 'treatment': self.player.treatment, # 'payment': self.player.payment, # } # class WelcomePage(Page): def is_displayed(self): return self.player.round_number == 1 def vars_for_template(self): self.player.treatment = self.player.participant.vars['treatment'] self.player.payment = self.player.participant.vars['payment'] return { 'treatment': self.player.treatment, 'payment': self.player.payment, **shared_vars(self), } form_model = 'player' form_fields = ['sex'] #class General_instructions(Page): # def is_displayed(self): # return self.player.round_number == 1 class Instructions1(Page): def is_displayed(self): return self.player.round_number == 1 class Instructions2(Page): def is_displayed(self): return self.player.round_number == 1 class ShuffleWaitPage(WaitPage): wait_for_all_groups = True def after_all_players_arrive(self): # self.subsession.set_player_endowment() self.subsession.sync_team_by_sex() self.subsession.group_players() groups = self.subsession.get_groups() matrix = self.subsession.get_group_matrix() for row in matrix: print(row) class Task(Page): timeout_seconds = Constants.time_limit form_model = 'player' def get_form_fields(self): return ['anagram_' + str(j) for j in range(1, Constants.total_number + 1)] def vars_for_template(self): return { 'treatment': self.participant.vars['treatment'], 'words_select_easy': self.participant.vars['words_select_easy'], 'words_select_medium': self.participant.vars['words_select_medium'], 'words_select_difficult': self.participant.vars['words_select_difficult'], 'anagram_select_easy': self.participant.vars['anagram_select_easy'], 'anagram_select_medium': self.participant.vars['anagram_select_medium'], 'anagram_select_difficult': self.participant.vars['anagram_select_difficult'], 'pair_select_easy': self.participant.vars['pair_select_easy'], 'pair_select_medium': self.participant.vars['pair_select_medium'], 'pair_select_difficult': self.participant.vars['pair_select_difficult'] **shared_vars(self), } def before_next_page(self): self.player.check_correct() print(self.player.payoff) print(self.player.correct) class Results(Page): timeout_seconds = 200 form_model = 'player' form_fields = ['groupiness'] def is_displayed(self): return self.player.round_number == Constants.num_rounds page_sequence = [ WelcomePage, Instructions1, Instructions2, ShuffleWaitPage, Task, Results ]