from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class part1(Page): def is_displayed(self): return self.player.participant.vars['QC_Fail'] > 0 form_model = 'player' form_fields = ['risk', 'loss_aversion', 'altruism'] class part2(Page): def is_displayed(self): return self.player.participant.vars['QC_Fail'] > 0 form_model = 'player' form_fields = ['gender', 'age', 'ethnicity', 'experience', 'practice'] class part3(Page): def is_displayed(self): return self.player.participant.vars['QC_Fail'] > 0 form_model = 'player' form_fields = ['experience', 'practice'] class Results(Page): def is_displayed(self): return self.player.participant.vars['QC_Fail'] > 0 def vars_for_template(self): return { 'round_selected': self.player.participant.vars['round_selected'], 'game_payment': self.player.participant.vars['final_payment']-Constants.initial_earning, 'final_payment': self.player.participant.vars['final_payment'], 'initial_earning': Constants.initial_earning } class Disqualify(Page): def is_displayed(self): return self.player.participant.vars['QC_Fail'] == 0 def vars_for_template(self): self.player.exit_detail = self.player.participant.vars['exit_detail'] consent = self.player.participant.vars['consent'] return { 'consent': consent, } def before_next_page(self): self.player.participant.payoff = 0 class Redirect(Page): def is_displayed(self): return self.player.participant.label != '' def vars_for_template(self): if self.player.participant.vars['QC_Fail'] > 0: url = "https://hub.m3globalresearch.com/survey_complete.cfm?survey_key=#survey_key#&user_id=#user_id#" else: url = "https://hub.m3globalresearch.com/survey_unqual.cfm?survey_key=#survey_key#&user_id=#user_id#" return { 'url': url, } page_sequence = [part1, part2, # part3, Results, Disqualify, Redirect ]