from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class Choice(Page): form_model = "player" form_fields = ["player_choice", "player_choice_past"] def vars_for_template(self): order = self.participant.vars["treatment_order"] return dict( # choice_type=Constants.types[order[self.round_number - 1] - 1], choice_type=self.player.round_number, image_path=Constants.pictures[order[self.round_number - 1] - 1], base_endowment=round( Constants.endowments[order[self.round_number - 1] - 1] ), user_chosen_decision=self.participant.vars["user_chosen_decision"], repetitions=Constants.repetitions[order[self.round_number - 1] - 1], repetitions_word=Constants.repetitions_words[ order[self.round_number - 1] - 1 ], ) def js_vars(self): # MARK min_time_in_modal is set manually at the moment # if self.round_number == 1: # min_time_in_modal = 0 # else: # min_time_in_modal = 0 return dict( choice_type=Constants.types[self.round_number - 1], user_chosen_decision=self.participant.vars["user_chosen_decision"], min_time_on_page=self.session.config["min_time_on_page_choice"], min_time_in_modal=self.session.config["min_time_on_page_choice_modal"], ) def before_next_page(self): if self.round_number == 1: self.participant.vars["player_choices"] = [self.player.player_choice] else: self.participant.vars["player_choices"].append(self.player.player_choice) class Repeated_announce(Page): def is_displayed(self): if self.round_number == 12: return True else: return False def js_vars(self): return dict( # min_time_in_modal=3, min_time_on_page=self.session.config["min_time_on_page_base"], user_chosen_decision=self.participant.vars["user_chosen_decision"], ) class Explanation(Page): form_model = "player" form_fields = [ "attention_check_1", "attention_check_2", "attention_check_3", "attention_check_4", "attention_check_5", "attention_check_6", "attention_check_7", "attention_check_8", "attention_check_9", "attention_check_10", "attention_check_11", # "explanation_entry_check", ] def is_displayed(self): if self.round_number == 12: return True else: return False def vars_for_template(self): return dict( choice_number="", image_path="repeat_choices/explain_repeated_gamble.png", base_endowment_init=round(self.session.config["base_endowment_init"]), user_chosen_decision=self.participant.vars["user_chosen_decision"], repetitions=4, ) def js_vars(self): return dict( # min_time_in_modal=3, min_time_on_page=self.session.config["min_time_on_page_choice"], user_chosen_decision=self.participant.vars["user_chosen_decision"], ) def error_message(self, values): if ( values["attention_check_1"] == -9999 or values["attention_check_2"] == -9999 or values["attention_check_3"] == -9999 or values["attention_check_4"] == -9999 or values["attention_check_5"] == -9999 or values["attention_check_6"] == -9999 or values["attention_check_7"] == -9999 or values["attention_check_8"] == -9999 or values["attention_check_9"] == -9999 or values["attention_check_10"] == -9999 or values["attention_check_11"] == -9999 # or values["explanation_entry_check"] == False ): msg = """Please answer all questions before trying to proceed.""" else: msg = "" return msg class ScreenAfterExplanation(Page): def is_displayed(self): if self.round_number == 12: return True else: return False def vars_for_template(self): return dict( choice_number="", user_chosen_decision=self.participant.vars["user_chosen_decision"], ) def js_vars(self): return dict( # min_time_in_modal=3, min_time_on_page=self.session.config["min_time_on_page_choice"], user_chosen_decision=self.participant.vars["user_chosen_decision"], ) page_sequence = [ Repeated_announce, Explanation, ScreenAfterExplanation, Choice # ]