from otree.api import expect, SubmissionMustFail from . import pages from ._builtin import Bot from .models import Constants class PlayerBot(Bot): cases = ['skip_all', 'fill_all'] def play_round(self): yield pages.Intro if self.case == 'skip_all': yield pages.Importance yield pages.Salience yield pages.Usage yield pages.Conformism yield pages.Exposure yield pages.Compliance yield pages.Mechanism else: form_values = { 'covid_risk_importance': 'Very important', 'covid_present_importance': 'Important', 'covid_grit_importance': 'Not important at all', 'covid_altruism_importance': 'Very important', 'covid_trust_importance': 'Important', 'covid_redistribution_importance': 'Very important', 'covid_cooperation_importance': 'Not important at all', 'covid_competition_importance': 'Important' } yield pages.Importance, form_values expect(self.player.covid_risk_importance, 'Very important') expect(self.player.covid_present_importance, 'Important') expect(self.player.covid_grit_importance, 'Not important at all') expect(self.player.covid_altruism_importance, 'Very important') expect(self.player.covid_trust_importance, 'Important') expect(self.player.covid_redistribution_importance, 'Very important') expect(self.player.covid_cooperation_importance, 'Not important at all') expect(self.player.covid_competition_importance, 'Important') too_many_salience_values = ['Altruism ',' Trust in others', 'Cooperation', 'Ease in a competitive environment] yield SubmissionMustFail(pages.Salience, {'salience': too_many_salience_values}) salience_values = ['Altruism ',' Trust in others'] yield pages.Salience, {'salience': salience_values} expect(self.player.salience, salience_values) too_many_usage_values = ['Altruism ',' Confidence in others', 'Cooperation ',' Ease in a competitive environment'] yield SubmissionMustFail(pages.Usage, {'usage': too_many_usage_values}) usage_values = ['Altruism ',' Confidence in others'] yield pages.Usage, {'usage': usage_values} expect(self.player.usage, usage_values) form_values = { 'covid_risk_change': 'remains constant', 'covid_present_change': 'reduced', 'covid_grit_change': 'increased', 'covid_altruism_change': 'remains constant', 'covid_trust_change': 'reduced', 'covid_redistribution_change': 'remains constant', 'covid_cooperation_change': 'increased', 'covid_competition_change': 'reduced', 'three_words': 'foo bar baz', 'time_to_normal': 'Some months', } yield pages.Conformism, form_values expect(self.player.covid_risk_change, 'remains constant') expect(self.player.covid_present_change, 'reduced') expect(self.player.covid_grit_change, 'increased') expect(self.player.covid_altruism_change, 'remains constant') expect(self.player.covid_trust_change, 'reduced') expect(self.player.covid_redistribution_change, 'remains constant') expect(self.player.covid_cooperation_change, 'increased') expect(self.player.covid_competition_change, 'reduced') expect(self.player.three_words, 'foo bar baz') expect(self.player.time_to_normal, 'Some months') form_values = { 'exposure_parents': ['Yes, my mother', 'Yes, my father'], 'exposure_infected': [ 'You', 'Your parents or siblings', 'Your grandparents', 'Another member of your family', 'A friend',], 'exposure_hospitalized': [ 'You', 'Your parents or siblings'], 'exposure_time_on_info': 'Less than 15 minutes', 'exposure_media': 'Online newspapers', 'exposure_media_newspaper': 'New York Times', } yield pages.Exposure, form_values expect(self.player.exposure_parents, form_values['exposure_parents']) expect(self.player.exposure_infected, form_values['exposure_infected']) expect(self.player.exposure_hospitalized, form_values['exposure_hospitalized']) expect(self.player.exposure_time_on_info, form_values['exposure_time_on_info']) expect(self.player.exposure_media, form_values['exposure_media']) expect(self.player.exposure_media_newspaper, form_values['exposure_media_newspaper']) form_values = { 'compliance_mask': 'Never', 'compliance_wash_hands': 'All the time', 'compliance_greet': 'Sometimes', 'compliance_distance': 'Most of the time', } yield pages.Compliance, form_values expect(self.player.compliance_mask, form_values['compliance_mask']) expect(self.player.compliance_wash_hands, form_values['compliance_wash_hands']) expect(self.player.compliance_greet, form_values['compliance_greet']) expect(self.player.compliance_distance, form_values['compliance_distance']) form_values = { 'mechanism_classmate_contact': '2-3 times a week', 'mechanism_teacher_contact': 'Never', 'mechanism_parents_at_home': ['Yes, my mother ',' Yes, my father'], 'mechanism_siblings_at_home': ['Yes, an older sibling (s) ', 'Yes, a younger brother or sister (s', 'I do not have any brother (s) or sister (s)'], 'mechanism_household_size': 4, 'mechanism_parents_unemployed': ['Yes, my mother ',' Yes, my father'], 'mechanism_feedback': 'help!' } yield pages.Mechanism, form_values expect(self.player.mechanism_classmate_contact, form_values['mechanism_classmate_contact']) expect(self.player.mechanism_teacher_contact, form_values['mechanism_teacher_contact']) expect(self.player.mechanism_parents_at_home, form_values['mechanism_parents_at_home']) expect(self.player.mechanism_siblings_at_home, form_values['mechanism_siblings_at_home']) expect(self.player.mechanism_household_size, form_values['mechanism_household_size']) expect(self.player.mechanism_parents_unemployed, form_values['mechanism_parents_unemployed']) expect(self.player.mechanism_feedback, form_values['mechanism_feedback'])