from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class WaitFoAllPlayersToArrive(WaitPage): wait_for_all_groups = True after_all_players_arrive = 'update_grouping' class Question1to5(Page): form_model = 'player' form_fields = [ 'q1', 'q2_year_of_birth', 'q2_age', 'q3', 'q3_other', 'q4', 'q4_other', 'q5', 'q5_other', ] def error_message(self, values): if values['q3'] == 'Other' and values['q3_other'] == None: return 'Please state your nationality.' if values['q4'] == 'Other' and values['q4_other'] == None: return 'Please state your ethnicity.' if values['q5'] == 'Other' and values['q5_other'] == None: return 'Please state your course of study.' def vars_for_template(self): return dict( participant_id=self.player.participant.id_in_session, group=self.player.group.id_in_subsession, ) class Question6to10(Page): form_model = 'player' form_fields = [ 'q6', 'q6_other', 'q7', 'q8', 'q9', 'q10', 'q10_other', ] def error_message(self, values): if values['q6'] == 'Other' and values['q6_other'] == None: return 'Please specify your language spoken at home.' if values['q9'] == 'Yes' and \ values['q10'] == 'Other' and \ values['q10_other'] == None: return 'Please state your religion.' if values['q9'] == 'Yes' and values['q10'] == None: return 'Please select your religion.' def vars_for_template(self): return dict( participant_id=self.player.participant.id_in_session, group=self.player.group.id_in_subsession, ) class Question11to15(Page): form_model = 'player' form_fields = [ 'q11', 'q12', 'q13', 'q14', 'q15' ] def vars_for_template(self): return dict( participant_id=self.player.participant.id_in_session, group=self.player.group.id_in_subsession, ) class Question16to19(Page): form_model = 'player' form_fields = [ 'q16', 'q17', 'q18', 'q19_family', 'q19_neighborhood', 'q19_people_personally', 'q19_people_first_time', 'q19_people_other_religion', 'q19_people_other_ethnicity', 'q19_people_other_lang', 'q19_people_other_nationality', ] def vars_for_template(self): return dict( q19=[ 'Trust completely', 'Trust somewhat', 'Do not trust very much', 'Do not trust at all' ], participant_id=self.player.participant.id_in_session, group=self.player.group.id_in_subsession, ) page_sequence = [WaitFoAllPlayersToArrive, Question1to5, Question6to10, Question11to15, Question16to19]