from otree.api import * import random c = Currency doc = """ This version is updated for not showing the partner's demographic information. """ # create dicts for news clips # The first digit indicates the group No., the second digit indicates the primary in-group order. ## RP news ls_RP = [ 'Recent statistics prove Republican mayors did better job than Democrats in improving homeless people’s condition.', 'GOP Senators Roger Wicker and Cindy Hyde-Smith cosponsored the enactment of a new legislation to strengthen partnerships between federal agencies and Historically Black Colleges and Universities.', 'GOP Sen. Roger Wicker intended to introduce a new bill that would provide a governing framework for the NCAA to allow athletes to make money while in college.', 'Republican Gov. Kay Ivey gave $1.9 million grant from Alabama’s Coronavirus Relief Fund to help veterans with post-traumatic stress disorder who got affected by COVID-19.', 'GOP Gov. Brad Little committed to transparency regarding the COVID-19 vaccine and directed the Idaho Department of Health and Welfare to carry out weekly virtual press briefings about the updates.', 'Republican Gov. Tate Reeves planned to take actions on accelerating COVID-19 vaccine rollout by eliminating roadblocks and doubling the sites.' ] ## RN news ls_RN = [ 'Sen. Ted Cruz, Texas Republican, faced calls for resignation after triggering mob storms Capitol Hill.', 'One of GOP Sen. Josh Hawley’s first major backers expressed buyer’s remorse and blasted the Missouri’s junior senator for his role in objecting to Joe Biden’s election victory.', 'Publisher canceled the forthcoming book by GOP Sen. Josh Hawley in response to his leading role in Capitol Hill riots.', 'Republican Gov. Doug Ducey declined to institute a statewide mask mandate even as Arizona became world “hotspot” for COVID-19.', 'Republican Gov. Tate Reeves, who violated many of his own orders like mask mandates and crowd size limits by hosting and attending fundraisers’ parties, received harsh public criticism.', 'Republican Senates Kelly Loeffler and David Perdue were investigated recently for allegedly engaging in pandemic-related insider trading.' ] ## DP news ls_DP = [ 'Democratic Gov. Jared Polis joined the Colorado Department of Public Health and Environment in asking the CDC for $10 million to help get COVID-19 vaccines to rural communities.', 'Connecticut became the first state in the nation to vaccinate all nursing home residents in the state with the first dose of COVID-19 vaccine, according to Democratic Gov. Ned Lemont.', 'Democratic Gov. John Carney and officials with the Delaware Department of Education announced $9 million in exchange for certification that recipients would not lay off educators or staff.', 'Democratic Gov. Gretchen Whitmer has signed $106 million bipartisan relief bill to provide families and small businesses support while also extending unemployment benefits to 26 weeks.', 'Democratic Gov. Steve Sisolak makes good on promise and continues to donate his quarterly salary of $27,218.98 to Nevada’s K12 public schools, accumulatively more than $187,000.', 'Democratic Gov. Tom Wolf announced $4.7 million for job training to bolster workforce development across Pennsylvania.' ] ## DN news ls_DN = [ 'California Democratic Governor Newsome disobeyed the quarantine practice that he announced to other Californians, attending a birthday party indoor at an elitist restaurant.', 'Top aide of President-elect, Antony Blinken, criticized for his early support for the Iraq War, reiterated the necessity of sending troops to the Mideast recently.', 'More than $320 million of dark money boosted Biden’s triumph in 2020 election, a recent analysis shows.', 'The Justice Department opened a probe into Democratic Sen. Tammy Baldwin for the possible insider trading of stocksales.', 'Democratic Gov. Andy Beshear faces impeachment from Kentucky House of representatives for his violation of both Kentucky Constitution and the U.S. Constitution in a series executive orders responding to the pandemic.', 'Democratic Gov. John Bel Edwards steered the vaccine distribution and accounted for the very poor consequence of the rollout in Louisiana.' ] ## EP news ls_EP = [ 'Apple was recently reported in talks with Hyundai about cooperating on building electric cars. More potential collaborators are in line.', 'The government was set to reopen its signature small business pandemic aid program with $284 billion in new funds and revamped rules that aim to get cash to the most needy businesses.', 'The auto industry faced recession in 2020 but ended on a surprisingly upbeat note, with car and truck sales rebounding sharply in Q4.', 'General Motors wants to electrify the delivery side of e-commerce, launching a new subsidiary that will deliver “an ecosystem” of products and services to speed up the shipping and delivery process.', 'Mexico sees holiday bump in tourism amid the coronavirus pandemic surge. Half of the 961,000 tourists that visited Qunitana Roo state are from the U.S.', 'U.S. stocks still keep drifting since 2021 starts, while Treasury yields keep marching higher amid expectations that the economy will pull out of its slump after a powerful recovery.' ] ## EN news ls_EN = [ 'JPMorgan estimates that the economic depression will continue in 2021 due to the great damage to local businesses caused by pandemic, even with positive vaccine developments.', 'Latest weekly total jobless benefit claims ticked sharply up another 10% more counts, amid the rise in coronavirus infections in past weeks.', 'Americans are running down their stock of savings and the poverty level spike again after the government assistance programs expire.', 'Nearly 4 million Americans have been out of work for at least six months due to the coronavirus pandemic.', 'As many as 14 million people faced potential delays or uncertainty because of bank accounts errors brought by IRS error.', 'Boeing will pay $2.5 billion to settle a Justice Department investigation and admit that employees misled regulators about the safety of its 737 Max aircraft, which suffered two deadly crashes shortly after entering airline service.' ] class Constants(BaseConstants): name_in_url = 'sharing_anony' players_per_group = 2 num_rounds = 1 payment = cu(1.50) endowment = cu(0.25) class Subsession(BaseSubsession): pass def creating_session(subsession): labels = range(0,99) for player, label in zip(subsession.get_players(), labels): player.participant.label = label class Group(BaseGroup): # Pre-game survey questions gender_p1 = models.StringField( label="What is your gender:", choices=['Male', 'Female', 'Other'], widget=widgets.RadioSelect, blank=False ) age_p1 = models.IntegerField( label="What is your age: (fill in with an integer from 18 to 100)", min=18, max=100, blank=False ) race_p1 = models.StringField( label="What is your race:", choices=[ 'White', 'Black', 'Hispanic', 'Asian', 'Other'], blank=False, widget=widgets.RadioSelect ) pid_p1 = models.StringField( label="Generally speaking, do you identify as a Republican, Democrat or an Independent?", choices=['Republican', 'Democrat', 'Independent'], blank=False, widget=widgets.RadioSelect ) gender_p2 = models.StringField( label="What is your gender:", choices=['Male', 'Female', 'Other'], widget=widgets.RadioSelect, blank=False ) age_p2 = models.IntegerField( label="What is your age: (fill in with an integer from 18 to 100)", min=18, max=100, blank=False ) race_p2 = models.StringField( label="What is your race:", choices=[ 'White', 'Black', 'Hispanic', 'Asian', 'Other'], blank=False, widget=widgets.RadioSelect ) pid_p2 = models.StringField( label="Generally speaking, do you identify as a Republican, Democrat or an Independent?", choices=['Republican', 'Democrat', 'Independent'], blank=False, widget=widgets.RadioSelect ) identity_p1 = models.IntegerField( label="Sometimes we define our identities in terms of the groups we belong to and other times by the groups that we do not belong to. When it comes to political parties, would you say your party affiliation is based more on belonging to your own party or NOT belonging to the other party?", choices=[ [1, 'Strongly based on identifying with my own party'], [2, 'Moderately based on identifying with my own party'], [3, 'Slightly based on identifying with my own party'], [4, 'Equally based on identifying with my own party and not identifying with the other party'], [5, 'Slightly based on not identifying with the other party'], [6, 'Moderately based on not identifying with the other party'], [7, 'Strongly based on not identifying with the other party'] ], widget=widgets.RadioSelect, blank=False ) identity_p2 = models.IntegerField( label="Sometimes we define our identities in terms of the groups we belong to and other times by the groups that we do not belong to. When it comes to political parties, would you say your party affiliation is based more on belonging to your own party or NOT belonging to the other party?", choices=[ [1, 'Strongly based on identifying with my own party'], [2, 'Moderately based on identifying with my own party'], [3, 'Slightly based on identifying with my own party'], [4, 'Equally based on identifying with my own party and not identifying with the other party'], [5, 'Slightly based on not identifying with the other party'], [6, 'Moderately based on not identifying with the other party'], [7, 'Strongly based on not identifying with the other party'] ], widget=widgets.RadioSelect, blank=False ) thermometer_dem_p1 = models.StringField( label="How do you feel toward Democrats?", choices=[ 'Very cold', 'Somewhat cold', 'Neutral', 'Somewhat warm', 'Very warm' ], blank=False, widget=widgets.RadioSelect ) thermometer_rep_p1 = models.StringField( label="How do you feel toward Republicans?", choices=[ 'Very cold', 'Somewhat cold', 'Neutral', 'Somewhat warm', 'Very warm' ], blank=False, widget=widgets.RadioSelect ) thermometer_dem_p2 = models.StringField( label="How do you feel toward Democrats?", choices=[ 'Very cold', 'Somewhat cold', 'Neutral', 'Somewhat warm', 'Very warm' ], blank=False, widget=widgets.RadioSelect ) thermometer_rep_p2 = models.StringField( label="How do you feel toward Republicans?", choices=[ 'Very cold', 'Somewhat cold', 'Neutral', 'Somewhat warm', 'Very warm' ], blank=False, widget=widgets.RadioSelect ) # set forms for news reading news_round1_p1 = models.StringField( label='Which news do you want to share with the other participant?', widget=widgets.RadioSelect, blank=False ) news_round1_p2 = models.StringField( label='Which news do you want to share with the other participant?', widget=widgets.RadioSelect, blank=False ) news_round2_p1 = models.StringField( label='Which news do you want to share with the other participant?', widget=widgets.RadioSelect, blank=False ) news_round2_p2 = models.StringField( label='Which news do you want to share with the other participant?', widget=widgets.RadioSelect, blank=False ) news_round3_p1 = models.StringField( label='Which news do you want to share with the other participant?', widget=widgets.RadioSelect, blank=False ) news_round3_p2 = models.StringField( label='Which news do you want to share with the other participant?', widget=widgets.RadioSelect, blank=False ) # token division appreciation_p1 = models.CurrencyField( min=0, max=Constants.endowment, label='How many dollars of your bonus do you want to give to your partner? (fill in the blank with a number from 0 to 0.25)', blank=False ) appreciation_p2 = models.CurrencyField( min=0, max=Constants.endowment, label='How many dollars of your bonus do you want to give to your partner? (fill in the blank with a number from 0 to 0.25)', blank=False ) def set_payoffs(group): p1 = group.get_player_by_id(1) p2 = group.get_player_by_id(2) p1.payoff = group.appreciation_p2 p2.payoff = group.appreciation_p1 # randomize the lists by group random.shuffle(ls_RP) random.shuffle(ls_RN) random.shuffle(ls_DP) random.shuffle(ls_DN) random.shuffle(ls_EP) random.shuffle(ls_EN) # randomize the choices for each form def news_round1_p1_choices(group): choices = [ls_RP[0], ls_RN[0],ls_DP[0],ls_DN[0],ls_EP[0],ls_EN[0]] random.shuffle(choices) return choices def news_round1_p2_choices(group): choices = [ls_RP[1], ls_RN[1],ls_DP[1],ls_DN[1],ls_EP[1],ls_EN[1]] random.shuffle(choices) return choices def news_round2_p1_choices(group): choices = [ls_RP[2], ls_RN[2],ls_DP[2],ls_DN[2],ls_EP[2],ls_EN[2]] random.shuffle(choices) return choices def news_round2_p2_choices(group): choices = [ls_RP[3], ls_RN[3],ls_DP[3],ls_DN[3],ls_EP[3],ls_EN[3]] random.shuffle(choices) return choices def news_round3_p1_choices(group): choices = [ls_RP[4], ls_RN[4],ls_DP[4],ls_DN[4],ls_EP[4],ls_EN[4]] random.shuffle(choices) return choices def news_round3_p2_choices(group): choices = [ls_RP[5], ls_RN[5],ls_DP[5],ls_DN[5],ls_EP[5],ls_EN[5]] random.shuffle(choices) return choices class Player(BasePlayer): # evaluate the interesting degree of the shared news clip in each round eval_novel_round1 = models.IntegerField( label="How interesting do you think this news clip is?", choices=[ [1, 'Not at all interesting'], [2, 'Slightly interesting'], [3, 'Neutral'], [4, 'Very interesting'], [5, 'Extremely interesting'] ], widget=widgets.RadioSelect, blank=False ) eval_novel_round2 = models.IntegerField( label="How interesting do you think this news clip is?", choices=[ [1, 'Not at all interesting'], [2, 'Slightly interesting'], [3, 'Neutral'], [4, 'Very interesting'], [5, 'Extremely interesting'] ], widget=widgets.RadioSelect, blank=False ) eval_novel_round3 = models.IntegerField( label="How interesting do you think this news clip is?", choices=[ [1, 'Not at all interesting'], [2, 'Slightly interesting'], [3, 'Neutral'], [4, 'Very interesting'], [5, 'Extremely interesting'] ], widget=widgets.RadioSelect, blank=False ) # evaluate the partner in general eval_trust = models.IntegerField( label='Based on the stories your partner shared, please rate your partner on a scale from 1 to 5, where 1 indicates that your partner cannot be trusted at all and 5 indicates that your partner can be trusted a lot.', min=1, max=5, blank=False ) eval_partisan = models.IntegerField( label="If you had to guess, would you say that your partner was a:", choices=[ [1, 'Strong Republican'], [2, 'Weak Republican'], [3, 'Leaning Republican'], [4, 'Independent'], [5, 'Leaning Democrat'], [6, 'Weak Democrat'], [7, 'Strong Democrat'] ], widget=widgets.RadioSelect, blank=False ) eval_attitude = models.IntegerField( label="If you had to guess, would you say that your partner was:", choices=[ [1, 'Extremely conservative'], [2, 'Somewhat conservative'], [3, 'Moderate'], [4, 'Somewhat liberal'], [5, 'Extremely liberal'], ], widget=widgets.RadioSelect, blank=False ) worker_id = models.StringField( label="Please type your MTurk worker ID here:", blank=False ) # PAGES class Welcome(Page): pass class PregameSurvey_P1(Page): form_model = 'group' @staticmethod def is_displayed(player): return player.id_in_group == 1 def get_form_fields(group): static_fields = ['gender_p1', 'age_p1', 'race_p1', 'pid_p1','identity_p1'] dynamic_fields = ['thermometer_rep_p1', 'thermometer_dem_p1'] random.shuffle(dynamic_fields) return static_fields + dynamic_fields class PregameSurvey_P2(Page): form_model = 'group' @staticmethod def is_displayed(player): return player.id_in_group == 2 def get_form_fields(group): static_fields = ['gender_p2', 'age_p2', 'race_p2', 'pid_p2','identity_p2'] dynamic_fields = ['thermometer_rep_p2', 'thermometer_dem_p2'] random.shuffle(dynamic_fields) return static_fields + dynamic_fields class ResultsWaitPage(WaitPage): title_text = "Please wait for your partner :)" body_text = "Your partner is almost done with the previous task. It usually takes no longer than 1 minute." pass class SurveyResult(Page): pass class News_P1_round1(Page): form_model = 'group' form_fields = ['news_round1_p1'] timeout_seconds = 150 @staticmethod def is_displayed(player): return player.id_in_group == 1 class News_P2_round1(Page): form_model = 'group' form_fields = ['news_round1_p2'] timeout_seconds = 150 @staticmethod def is_displayed(player): return player.id_in_group == 2 class News_P1_round2(Page): form_model = 'group' form_fields = ['news_round2_p1'] timeout_seconds = 150 @staticmethod def is_displayed(player): return player.id_in_group == 1 class News_P2_round2(Page): form_model = 'group' form_fields = ['news_round2_p2'] timeout_seconds = 150 @staticmethod def is_displayed(player): return player.id_in_group == 2 class News_P1_round3(Page): form_model = 'group' form_fields = ['news_round3_p1'] timeout_seconds = 150 @staticmethod def is_displayed(player): return player.id_in_group == 1 class News_P2_round3(Page): form_model = 'group' form_fields = ['news_round3_p2'] timeout_seconds = 150 @staticmethod def is_displayed(player): return player.id_in_group == 2 class Receive_round1(Page): form_model = 'player' form_fields = ['eval_novel_round1'] class Receive_round2(Page): form_model = 'player' form_fields = ['eval_novel_round2'] class Receive_round3(Page): form_model = 'player' form_fields = ['eval_novel_round3'] class PostgameSurvey1(Page): form_model = 'player' form_fields = ['eval_trust','eval_partisan','eval_attitude'] class PostgameSurvey2_p1(Page): form_model = 'group' form_fields = ['appreciation_p1'] @staticmethod def is_displayed(player): return player.id_in_group == 1 class PostgameSurvey2_p2(Page): form_model = 'group' form_fields = ['appreciation_p2'] @staticmethod def is_displayed(player): return player.id_in_group == 2 class BonusWaitPage(WaitPage): after_all_players_arrive = set_payoffs class PostgameSurvey3(Page): form_model = 'player' form_fields = ['worker_id'] class EndPage(Page): pass page_sequence = [ Welcome, PregameSurvey_P1, PregameSurvey_P2, ResultsWaitPage, News_P1_round1, News_P2_round1, ResultsWaitPage, Receive_round1, #Receive_P1_round1, Receive_P2_round1, News_P1_round2, News_P2_round2, ResultsWaitPage, Receive_round2, #Receive_P1_round2, Receive_P2_round2, News_P1_round3, News_P2_round3, ResultsWaitPage, #Receive_P1_round3, Receive_P2_round3, Receive_round3, PostgameSurvey1, PostgameSurvey2_p1, PostgameSurvey2_p2, BonusWaitPage, PostgameSurvey3, EndPage ]