from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class Introduction(Page): form_model = 'player' form_fields = ['consent'] def is_displayed(self): self.player.browser = self.request.META.get('HTTP_USER_AGENT') return True class Knowledge(Page): form_model = 'player' form_fields = ['knowledge'] def is_displayed(self): if self.player.survey_initial and not self.player.scenario_completed and self.player.consent: return True elif not self.player.survey_initial and self.player.scenario_completed and self.player.consent: return True else: return False class Empathy(Page): form_model = 'player' form_fields = ['empathy'] def is_displayed(self): if self.player.survey_initial and not self.player.scenario_completed and self.player.consent: return True elif not self.player.survey_initial and self.player.scenario_completed and self.player.consent: return True else: return False def vars_for_template(self): import random # Define CI/MI Matrix pt_text = [ ['id_pt_1', 'I sometimes find it difficult to see things from the "other guy\'s" point of view.'], ['id_pt_2', 'I try to look at everybody\'s side of a disagreement before I make a decision.'], ['id_pt_3', 'I sometimes try to understand my friends better by imagining how things look from their ' 'perspective.'], ['id_pt_4', 'If I\'m sure I\'m right about something, I don\'t waste much time listening to other ' 'people\'s arguments.'], ['id_pt_5', 'I believe that there are two sides to every question and try to look at them both.'], ['id_pt_6', 'When I\'m upset at someone, I usually try to "put myself in his shoes" for a while.'], ['id_pt_7', 'Before criticizing somebody, I try to imagine how I would feel if I were in their place.'] ] random.shuffle(pt_text) return {'pt': pt_text} class World(Page): form_model = 'player' form_fields = ['attention', 'world' ] def is_displayed(self): if self.player.survey_initial and not self.player.scenario_completed and self.player.consent: return True elif not self.player.survey_initial and self.player.scenario_completed and self.player.consent: return True else: return False def vars_for_template(self): import random # Define CI/MI Matrix cimi_text = [ ['id_cop_1', 'Your country needs to cooperate more with the United Nations and/or regional ' 'cooperation organizations.'], ['id_cop_2', 'It is essential for your country to work with other nations to solve problems ' 'such as overpopulation, hunger, and pollution.'], ['id_cop_3', 'Protecting the environment and ensuring universal access to safe, secure global ' 'common spaces (oceans, airspace, etc.) is of utmost importance.'], ['id_mil_1', 'Your country should take all steps including the use of force to prevent aggression ' 'by any expansionist power.'], ['id_mil_2', 'Rather than simply countering our opponents’ thrusts, it is necessary to strike at ' 'the heart of an opponent’s power.'], ['id_mil_3', 'It is sometimes necessary that your country must demonstrate its resolve so that ' 'others do not take advantage of it.'], ['id_neu_1', 'Your country should mind its own business internationally and, so long as they ' 'don’t threaten you, let other countries get along the best they can on their own.'], ['id_neu_2', 'Your country needs to play an active role in solving conflicts around the world.'], ['id_neu_3', 'Your country’s close partners are perfectly capable of defending themselves and ' 'they can afford it. Since they can defend themselves, they should; thus allowing us ' 'to focus on domestic issues rather than external problems.'], ['id_att', 'Paying attention is important. Move the slider to "Completely Agree".'] ] random.shuffle(cimi_text) return {'cimi': cimi_text} class Risk(Page): form_model = 'player' form_fields = ['risk'] def is_displayed(self): if self.player.survey_initial and not self.player.scenario_completed and self.player.consent: return True elif not self.player.survey_initial and self.player.scenario_completed and self.player.consent: return True else: return False class Demographics(Page): form_model = 'player' form_fields = ['age', 'gender', 'education', 'political', 'computer', 'income', 'outage' ] def is_displayed(self): if self.player.survey_initial and not self.player.scenario_completed and self.player.consent: return True elif not self.player.survey_initial and self.player.scenario_completed and self.player.consent: return True else: return False class Scenario(Page): form_model = 'player' form_fields = ['endorse'] def is_displayed(self): return self.player.consent class Checks(Page): form_model = 'player' form_fields = ['capability_check', 'culture_check'] def is_displayed(self): return self.player.consent class Reason(Page): form_model = 'player' form_fields = ['reason'] def is_displayed(self): return self.player.consent def before_next_page(self): self.player.scenario_completed = True class Closing(Page): pass page_sequence = [ Introduction, Knowledge, Empathy, World, Risk, Demographics, Scenario, Reason, Checks, Knowledge, Empathy, World, Risk, Demographics, Closing ]