from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants from random import shuffle from datetime import datetime # Participant consent page class Consent(Page): form_model = 'player' form_fields = ['consent'] def before_next_page(self): # Capture browser to diagnose possible errors during pilot testing self.player.browser = self.request.META.get('HTTP_USER_AGENT') # Participant Disposition instrument (Kertzer & McGraw, 2012; Ehrlich & Maestas) class Disposition(Page): form_model = 'player' form_fields = ['attention', 'cooperative_1', 'cooperative_2', 'cooperative_3', 'militant_1', 'militant_2', 'militant_3', 'militant_4', 'isolationist_1', 'isolationist_2', 'isolationist_3', 'sovereign_1', 'sovereign_2', 'sovereign_3' ] def vars_for_template(self): questions = [ ['cooperative_1', 'id_cooperative_1', 'Your country needs to cooperate more with the United Nations and/or' ' regional cooperation organizations.'], ['cooperative_2', 'id_cooperative_2', 'It is essential for your country to work with other nations to solve' ' problems such as overpopulation, hunger, and pollution.'], ['cooperative_3', 'id_cooperative_3', 'Protecting the environment and ensuring universal access to safe, ' 'secure global common spaces (oceans, airspace, etc.) is of utmost ' 'importance.'], ['militant_1', 'id_militant_1', 'Your country should take all steps including the use of force to prevent ' 'aggression by any expansionist power.'], ['militant_2', 'id_militant_2', 'Rather than simply countering our opponents’ thrusts, it is necessary to ' 'strike at the heart of an opponent\'s power.'], ['militant_3', 'id_militant_3', 'Going to war is unfortunate but sometimes the only solution to ' 'international problems.'], ['militant_4', 'id_militant_4', 'It is sometimes necessary that your country must demonstrate its resolve ' 'so that others do not take advantage of it.'], ['isolationist_1', 'id_isolationist_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.'], ['isolationist_2', 'id_isolationist_2', 'Your country needs to play an active role in solving conflicts ' 'around the world.'], ['isolationist_3', 'id_isolationist_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.'], ['sovereign_1', 'id_sovereign_1', 'Your country should not allow the establishment of foreign military ' 'facilities (e.g., bases and outposts) in your territory.'], ['sovereign_2', 'id_sovereign_2', 'Foreign military aircraft should not be allowed to transit through your ' 'territorial airspace without prior authorization.'], ['sovereign_3', 'id_sovereign_3', 'Your country should allow foreign intelligence agencies to pursue ' 'terrorists operating in your territory.'], ['attention', 'id_attention', 'Please select "Strongly Agree".'] ] # Shuffle to avoid order effects shuffle(questions) return dict(items=questions) def before_next_page(self): self.player.isolationist_2 = 7 - self.player.isolationist_2 self.player.sovereign_3 = 7 - self.player.sovereign_3 # To manage the randomized order of the demographics and covariate questions def is_displayed(self): if self.player.initial and not self.player.completed and self.player.consent: return True elif not self.player.initial and self.player.completed and self.player.consent: return True else: return False # Participant domain expertise instrument class Expertise(Page): form_model = 'player' form_fields = ['knowledge_1', 'knowledge_2', 'knowledge_3', 'knowledge_4', 'knowledge_5', 'knowledge_6', ] def vars_for_template(self): questions = [ ['knowledge_1', 'id_knowledge_1', 'Which country is frequently associated with the theft of proprietary information by cyber means?', 'The United States', 'Russia', 'China', 'North Korea', 'I Don\'t Know'], ['knowledge_2', 'id_knowledge_2', 'What is a DDoS?', 'A form of commercial advertising using online ads', 'A program or worm designed to infiltrate a computer system', 'An attack that uses multiple computers to overload and shut down a targeted system', 'A program used to send ‘spam’ email to multiple accounts at once', 'I Don\'t Know'], ['knowledge_3', 'id_knowledge_3', 'What is Phishing?', 'An email that steals passwords by appearing to be from an individual or business that you know', 'A malware program that uses a computer network to spread itself and gain access or shutdown the network', 'Defrauding an online account holder of financial information by posing as a legitimate company', 'A network of private computers infected with malicious software and controlled without the owner’s knowledge', 'I Don\'t Know'], ['knowledge_4', 'id_knowledge_4', 'What was the presumed reason for the 2014 hack of US Film Company Sony Pictures Entertainment in 2014?', 'Sony executives\' rumored connection to Chechyan rebels in Russia', 'Sony\'s production of a film that insulted North Korean leader Kim Jung-un', 'Sony\'s history of producing \'immodest\' films that angered Iranian leadership', 'Sony executives\' support for the Tibet independence movement', 'I Don\'t Know'], ['knowledge_5', 'id_knowledge_5', 'What country’s nuclear program was affected by the Stuxnet computer virus?', 'Israel', 'China', 'Saudi Arabia', 'Iran', 'I Don\'t Know'], ['knowledge_6', 'id_knowledge_6', 'What is a Trojan Horse?', 'A program that records keystrokes by the user in order to steal passwords for accounts', 'Malware that installs itself on a computer and freezes it until some type of \'ransom\' is paid', 'A virus that replicates itself or infects and modifies other programs on a computer without user consent', 'A malicious computer program designed to hack into a computer by misleading users of its true intent', 'I Don\'t Know'] ] # Shuffle to avoid order effects shuffle(questions) return dict(items=questions) # To manage the randomized order of the demographics and covariate questions def is_displayed(self): if self.player.initial and not self.player.completed and self.player.consent: return True elif not self.player.initial and self.player.completed and self.player.consent: return True else: return False # Participant demographic page class Demographics(Page): form_model = 'player' form_fields = [ 'age', 'gender', 'education', 'income', 'resident', 'malware' ] def before_next_page(self): self.player.age = datetime.now().year - self.player.age # To manage the randomized order of the demographics and covariate questions def is_displayed(self): if self.player.initial and not self.player.completed and self.player.consent: return True elif not self.player.initial and self.player.completed and self.player.consent: return True else: return False # Scenario page class Scenario(Page): def vars_for_template(self): dayt = datetime.today().day montht = datetime.today().strftime("%B") yeart = datetime.today().year return dict(day=dayt, month=montht, year=yeart) def is_displayed(self): if self.player.consent: return True else: return False class Emotions(Page): form_model = 'player' form_fields = [ 'anxiety_1', 'anxiety_2', 'anxiety_3', 'anxiety_4', 'anxiety_5', 'anxiety_6', 'anger_1', 'anger_2', 'anger_3', 'anger_4', ] def vars_for_template(self): questions = [ ['anxiety_1', 'id_anxiety_1', 'Do you feel tense?'], ['anxiety_2', 'id_anxiety_2', 'Do you feel calm?'], ['anxiety_3', 'id_anxiety_3', 'Do you feel relaxed?'], ['anxiety_4', 'id_anxiety_4', 'Do you feel upset?'], ['anxiety_5', 'id_anxiety_5', 'Do you feel content?'], ['anxiety_6', 'id_anxiety_6', 'Do you feel worried?'], ['anger_1', 'id_anger_1', 'Are you mad?'], ['anger_2', 'id_anger_2', 'Do you feel irritated?'], ['anger_3', 'id_anger_3', 'Do you feel angry?'], ['anger_4', 'id_anger_4', 'Are you furious?'], ] # Shuffle to avoid order effects shuffle(questions) return dict(items=questions) def before_next_page(self): self.player.anxiety_2 = 7 - self.player.anxiety_2 self.player.anxiety_3 = 7 - self.player.anxiety_3 self.player.anxiety_5 = 7 - self.player.anxiety_5 def is_displayed(self): if self.player.consent: return True else: return False class Dread(Page): form_model = 'player' form_fields = [ 'dread_1', 'dread_2', 'dread_3', 'dread_4', 'dread_5', 'dread_6', 'dread_7', 'dread_8', 'dread_9', 'dread_10', ] def vars_for_template(self): questions = [ ['dread_1', 'id_dread_1', 'Cyberspace is a deceptive environment.'], ['dread_2', 'id_dread_2', 'I have confidence in cyberspace.'], # Reversed ['dread_3', 'id_dread_3', 'Cyberspace operates in a fraudulent manner.'], ['dread_4', 'id_dread_4', 'The integrity of information is preserved in cyberspace.'], # Reversed ['dread_5', 'id_dread_5', 'I am suspicious of actions and outcomes in and through cyberspace.'], ['dread_6', 'id_dread_6', 'Cyberspace is a reliable environment.'], # Reversed ['dread_7', 'id_dread_7', 'I am wary of cyberspace.'], ['dread_8', 'id_dread_8', 'I can trust cyberspace.'], # Reversed ['dread_9', 'id_dread_9', 'Harmful or injurious outcomes occur through cyberspace.'], ['dread_10', 'id_dread_10', 'I am familiar with how cyberspace functions.'] # Reversed ] # Shuffle to avoid order effects shuffle(questions) return dict(items=questions) def before_next_page(self): self.player.dread_2 = 7 - self.player.dread_2 self.player.dread_4 = 7 - self.player.dread_4 self.player.dread_6 = 7 - self.player.dread_6 self.player.dread_8 = 7 - self.player.dread_8 self.player.dread_10 = 7 - self.player.dread_10 def is_displayed(self): if self.player.consent: return True else: return False class Outcome(Page): form_model = 'player' form_fields = [ 'censure', 'cooperate', 'interest', 'consequences', 'responsible', 'state_target' ] def is_displayed(self): if self.player.consent: return True else: return False class Manipulation(Page): form_model = 'player' form_fields = [ 'supportive_check', 'partner_check', 'state_check' ] def is_displayed(self): if self.player.consent: return True else: return False def before_next_page(self): self.player.completed = True # Closing page class Closing(Page): pass page_sequence = [ Consent, Disposition, Expertise, Demographics, Scenario, Emotions, Dread, Outcome, Manipulation, Disposition, Expertise, Demographics, Closing ]