from . import models from ._builtin import Page, WaitPage from otree.api import Currency as c, currency_range from .models import Constants class Demographics(Page): form_model = 'player' form_fields = ['q_country', 'q_age', 'q_gender', 'q_major', 'q_exp', 'q_strategy'] def before_next_page(self): self.player.set_payoff() def error_message(self, values): # if len(values['q_strategy']) < 100: # return "Please give a longer answer of at least 100 characters." if values['q_country'] is None or values['q_age'] is None or values['q_gender'] is None \ or values['q_major'] is None or values['q_exp'] is None or values['q_strategy'] is None: return "Please answer all the questions before proceed." class ACTION_questionnaire_wait(Page): def before_next_page(self): self.player.set_payoff() class PaymentInfo(Page): def vars_for_template(self): my_label = self.participant.label return { 'label': my_label[1:], 'show_up_fee': self.session.config['participation_fee'], 'PayoffT1': self.participant.vars['PayoffT1'], 'PayoffT2': self.participant.vars['PayoffT2a']*2, 'T3pr1': self.participant.vars['paying_round_1'], 'T3pr2': self.participant.vars['paying_round_2'], 'T3Payoff': self.participant.vars['T3payoff'], 'PayoffT4': self.participant.vars['PayoffT4a']*2, 'PayoffT5': self.participant.vars['PayoffT5'], 'PayoffT6': self.participant.vars['PayoffT6'], 'PayoffT7': self.participant.vars['PayoffT7'], 'all_task_payoff': self.participant.payoff.to_real_world_currency(self.session), 'total_payoff': self.participant.payoff_plus_participation_fee(), } page_sequence = [ ACTION_questionnaire_wait, Demographics, PaymentInfo, ]