from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants from django.views.decorators.csrf import csrf_exempt from django.utils.decorators import method_decorator import numpy as np def vars_for_all_templates(self): return { 'participation_fee': c(self.session.config['participation_fee']), 'radio_amounts': zip(Constants.list2, Constants.list1), 'round': self.round_number, 'exp_duration': self.session.config['exp_duration'], } @method_decorator(csrf_exempt, name='dispatch') class ProlificID(Page): def is_displayed(self): return self.round_number == 1 form_model = 'player' form_fields = ['prolific_id'] class Welcome(Page): def is_displayed(self): return self.round_number == 1 class Consent(Page): def is_displayed(self): return self.round_number == 1 form_model = 'player' form_fields = ['consent'] def app_after_this_page(self, upcoming_apps): if not self.player.consent: self.participant.vars['consent'] = False return upcoming_apps[-1] class Result(Page): def is_displayed(self): return True # timeout_seconds = 5 class GroupWaitPage(WaitPage): def is_displayed(self): return True group_by_arrival_time = True class ResultWaitPage(WaitPage): def is_displayed(self): return True after_all_players_arrive = 'set_payoffs' class AA_ry(Page): live_method = 'live_aa' def is_displayed(self): return True form_model = 'player' form_fields = ['bid', 'bid_help', 'stop_help'] def js_vars(self): return { 'id': self.player.id_in_group } class Auction(Page): live_method = 'live_aa' def is_displayed(self): return True form_model = 'player' form_fields = ['bid', 'bid_help', 'stop_help'] def js_vars(self): return { 'id': self.player.id_in_group } def get_timeout_seconds(self): if self.player.current_play == "aa": return None else: return 90 timer_text = 'Time Remaining:' class Valuation(Page): def is_displayed(self): return True form_model = 'player' form_fields = ['confidence'] class AuctionWaitPage(WaitPage): def is_displayed(self): return True class AuctionInstructions(Page): def is_displayed(self): instruction_round = [1,2,3] return self.round_number in instruction_round class FinishedTasks(Page): def is_displayed(self): return self.round_number == Constants.num_rounds class PayoffandGoodbye(Page): def is_displayed(self): return self.round_number == Constants.num_rounds page_sequence = [ GroupWaitPage, AuctionInstructions, Valuation, AuctionWaitPage, Auction, ResultWaitPage, Result, FinishedTasks, PayoffandGoodbye ]