Пример #1
0
class Player(BasePlayer):
    moneyLeft = models.IntegerField(initial=0)
    spent = models.IntegerField(initial=0)
    sumContribution = models.IntegerField(initial=0)
    contribution = models.IntegerField(initial=0)

    contribution1 = models.IntegerField(min=0,
                                        max=Constants.endowment,
                                        initial=0,
                                        label="How much will you contribute?")

    contribution2 = models.IntegerField(min=0,
                                        max=Constants.endowment,
                                        initial=0,
                                        label="How much will you contribute?")

    contribution3 = models.IntegerField(min=0,
                                        max=Constants.endowment,
                                        initial=0,
                                        label="How much will you contribute?")

    contribution4 = models.IntegerField(min=0,
                                        max=Constants.endowment,
                                        initial=0,
                                        label="How much will you contribute?")

    contribution5 = models.IntegerField(min=0,
                                        max=Constants.endowment,
                                        initial=0,
                                        label="How much will you contribute?")

    contribution6 = models.IntegerField(min=0,
                                        max=Constants.endowment,
                                        initial=0,
                                        label="How much will you contribute?")

    contribution7 = models.IntegerField(min=0,
                                        max=Constants.endowment,
                                        initial=0,
                                        label="How much will you contribute?")

    contribution8 = models.IntegerField(min=0,
                                        max=Constants.endowment,
                                        initial=0,
                                        label="How much will you contribute?")

    contribution9 = models.IntegerField(min=0,
                                        max=Constants.endowment,
                                        initial=0,
                                        label="How much will you contribute?")

    contribution10 = models.IntegerField(min=0,
                                         max=Constants.endowment,
                                         initial=0,
                                         label="How much will you contribute?")
Пример #2
0
class Group(BaseGroup):
    def generate_movie_options(self):
        for name, movie in self.movies().items():
            movieObj = self.movieselection_set.create(
                group=self,
                key=name,
                name=movie["title"],
                description=movie["description"],
                embeddedVideo=movie["videoId"],
                isRemaining=True,
                isChecked=False)
            movieObj.save()

    def movies(self):
        return {
            'intouchables': {
                "videoId": "34WIbmXkewU",
                "description":
                "<strong> The Intouchables </strong>(Foreign) – two very different men bond and develop a very close relationship",
                "title": "The Intouchables"
            },
            'starfish': {
                "videoId": "U5XnW3c8P-Y",
                "description":
                "<strong> Starfish </strong>(Science Fiction) – a young woman struggles with the death of her best friend",
                "title": "Starfish"
            },
            'versailles': {
                "videoId": "LQW9Ks0GZUQ",
                "description":
                "<strong>The Queen of Versailles </strong>(Documentary) – the economic crisis threatens the fortune of a billionaire family",
                "title": "The Queen of Versailles"
            },
            'hush': {
                "videoId": "Q_P8WCbhC6s",
                "description":
                "<strong>Hush </strong>(Horror) – a deaf writer living in the woods fights for her life when a killer appears in her window",
                "title": "Hush"
            },
            'father': {
                "videoId": "_bfqsNh6U7c",
                "description":
                "<strong> Like Father </strong> (Rom-com) – a woman left at the altar takes her estranged father on her honeymoon",
                "title": "Like Father"
            },
            'tomboy': {
                "videoId": "Jb-Oys-IcWE",
                "description":
                "<strong> Tomboy </strong> (Drama) - a 10-year old girl experiments with with her gender identity over the summer",
                "title": "Tomboy"
            },
            'phoenix': {
                "videoId": "1-q8C_c-nlM",
                "description":
                "<strong>Dark Phoenix </strong>(Science Fiction/Action) – the X-Men embark on a risky mission in space",
                "title": "Dark Phoenix"
            },
            'shazam': {
                "videoId": "Y5I4TA0yhr4",
                "description":
                "<strong>Shazam! </strong>(Superhero) - a 14-year-old transforms into an adult superhero with one magic word",
                "title": "Shazam!"
            },
            'dumbo': {
                "videoId": "7NiYVoqBt-8",
                "description":
                "<strong>Dumbo </strong>(Fantasy) - a man and his two children take care of a newborn elephant that can fly",
                "title": "Dumbo"
            },
            'survivalist': {
                "videoId": "KNADbtHsIU8",
                "description":
                "<strong>The Survivalist </strong>(Thriller) - a survivalist hides in the forest protecting his crop from intruders",
                "title": "The Survivalist"
            },
            'carol': {
                "videoId": "679wr31SXWk",
                "description":
                "<strong>Carol </strong>(Romance) - two women develop a fast bond that becomes a love with complicated consequences",
                "title": "Carol"
            },
            'wild': {
                "videoId": "tn2-GSqPyl0",
                "description":
                "<strong> Wild </strong>(Adventure) - a woman's solo undertakes a hike as a way to recover from a recent personal tragedy",
                "title": "Wild"
            }
        }

    eliminateNegative = models.BooleanField(initial=True)

    goal = models.BooleanField()
    chat = models.StringField()
    chat2 = models.StringField()
    volleyLots = models.BooleanField()
    has_selected = models.BooleanField(initial=False)

    def get_movies(self):
        return MovieSelection.objects.filter(group__exact=self)

    def get_remaining_movies(self):
        return self.get_movies().filter(isRemaining=True)

    def get_eliminated_movies(self):
        return self.get_movies().filter(isRemaining=False)

    def get_eliminated_movie_descriptions(self):
        return map(lambda mov: mov.description, self.get_eliminated_movies())

    def get_remaining_movie_names(self):
        return map(lambda mov: mov.name, self.get_remaining_movies())

    def volleying(self):
        return not len(self.get_remaining_movies()) == 1

    def last_movie(self):
        return "" if len(self.get_remaining_movies()) == 0 else list(
            self.get_remaining_movies())[0]

    def last_movie_name(self):
        return "" if len(self.get_remaining_movies()
                         ) == 0 else self.get_remaining_movies()[0].name

    def last_movie_key(self):
        return "" if len(self.get_remaining_movies()
                         ) == 0 else self.get_remaining_movies()[0].key

    numberVolleys = models.IntegerField(initial=0)

    volley = models.LongStringField(initial="")
Пример #3
0
def make_field_satisfaction(index):
    return models.IntegerField(
        label=Constants.satisfaction[index - 1],
        widget=widgets.RadioSelectHorizontal,
        choices=Constants.L53_CHOICES,
    )
Пример #4
0
class Player(BasePlayer):
    participant_code = models.StringField(label = 'Šifra - unesite prva dva slova imena oca, zadnja dva slova imena majke,\
                                          i zadnje dvije znamenke u broju mobitela. Pri tome nemojte koristiti dijakritičke\
                                          znakove, a slova poput "nj" tretirajte kao dva slova.')
    dob = models.IntegerField(min=14, max=40)
    spol = models.StringField(widget = widgets.RadioSelect)
Пример #5
0
income = models.StringField(
    label="Wat is (ongeveer) het netto maandelijks inkomen van uw gehele huishouden?",
    choices=["Minder dan €499", "Tussen €500 en €999", "Tussen €1000 en €1499",
             "Tussen €1500 en €1999", "Tussen €2000 en €2499", "Tussen €2500 en €2999",
             "Tussen €3000 en €3499", "Tussen €3500 en €3999", "Tussen €4000 en €4499",
             "Tussen €4500 en €4999", "€5000 of meer", "Dat weet ik niet", "Zeg ik liever niet"])

floor = models.StringField(label="Hoe zou uw huis omschrijven?")
edu = models.StringField(label="Wat is uw hoogst voltooide opleiding?")

postcode = models.StringField(
    label="Wat is uw postcode?",
    blank=True)

postcode_cijfers = models.IntegerField(blank=True)
postcode_letters = models.StringField(blank=True)

insurance = models.StringField(
    label="Wat is uw eigen risico voor uw zorgverzekering van 2018?",
    choices=["385 euro, het minimum vastgesteld door de Nederlandse overheid",
             "485 euro, ik heb het opgehoogd met 100 euro",
             "585 euro, ik heb het opgehoogd met 200 euro",
             "685 euro, ik heb het opgehoogd met 300 euro",
             "785 euro, ik heb het opgehoogd met 400 euro",
             "885 euro, ik heb het opgehoogd met 500 euro (het maximum)",
             "Dat weet ik niet",
             'Ik heb geen Nederlandse zorgverzekering'])

ins = (("tandarts", "Tandartsverzekering"),
       ('aanvullend', "Ander aanvullend pakket in zorgverzekering (o.a. fysiotherapie, bril)"),
Пример #6
0
class Group(BaseGroup):
    num_random_conceal = models.IntegerField()

    def set_random_conceal(self):
        self.num_random_conceal = random.choice(Constants.max_conceal)
Пример #7
0
class Player(BasePlayer):
    onay_1 =  models.StringField(
        choices=['Deney linkimi kimseyle paylaşmayacağımı onaylıyorum'],
        widget=widgets.RadioSelect) 
    
    onay_2 =  models.StringField(
        choices=['Deney süresince Zoom oturumunu terketmeyeceğim ve cihazın sesini duyuruları işitecek şekilde açık tutacağım'],
        widget=widgets.RadioSelect) 

    onay_3 =  models.StringField(
        choices=['Deney süresince diğer katılımcılarla iletişim kurmayacağımı onaylıyorum.'],
        widget=widgets.RadioSelect) 
    
    onay_4 =  models.StringField(
        choices=['Deney tamamlanmadan deneyi terketmeyeceğimi onaylıyorum.'],
        widget=widgets.RadioSelect) 

    q1 = models.StringField(
        choices=Constants.q1_choices,
        label= Constants.question_1, 
        widget=widgets.RadioSelect)
    
    q1_is_correct = models.BooleanField()
    q1_dogru = models.StringField()
    def check_correct_q1(self):
        self.q1_is_correct = (self.q1 == Constants.s1)
        if self.q1_is_correct:
            self.q1_dogru = "Doğru"
        else:
            self.q1_dogru = "Yanlış"
    q2 = models.StringField(
        choices=Constants.q2_choices,
        label= Constants.question_2, 
        widget=widgets.RadioSelect)
    
    q2_is_correct = models.BooleanField()
    q2_dogru = models.StringField()
    def check_correct_q2(self):
        self.q2_is_correct = (self.q2 == Constants.s2)
        if self.q2_is_correct:
            self.q2_dogru = "Doğru"
        else:
            self.q2_dogru = "Yanlış"
    
    q3 = models.StringField(
        choices=Constants.q3_choices,
        label= Constants.question_3, 
        widget=widgets.RadioSelect)
    
    q3_is_correct = models.BooleanField()
    q3_dogru = models.StringField()
    def check_correct_q3(self):
        self.q3_is_correct = (self.q3 == Constants.s3)
        if self.q3_is_correct:
            self.q3_dogru = "Doğru"
        else:
            self.q3_dogru = "Yanlış"
    q4 = models.StringField(
        choices=Constants.q4_choices,
        label= Constants.question_4, 
        widget=widgets.RadioSelect)
    
    q4_is_correct = models.BooleanField()
    q4_dogru = models.StringField()
    def check_correct_q4(self):
        self.q4_is_correct = (self.q4 == Constants.s4)
        if self.q4_is_correct:
            self.q4_dogru = "Doğru"
        else:
            self.q4_dogru = "Yanlış"

    q5 = models.StringField(
        choices=Constants.q5_choices,
        label= Constants.question_5, 
        widget=widgets.RadioSelect)
    
    q5_is_correct = models.BooleanField()
    q5_dogru = models.StringField()
    def check_correct_q5(self):
        self.q5_is_correct = (self.q5 == Constants.s5)
        if self.q5_is_correct:
            self.q5_dogru = "Doğru"
        else:
            self.q5_dogru = "Yanlış"
    
    questions_correct = models.IntegerField()
    def q_correct(self):
        self.questions_correct = self.q1_is_correct + self.q2_is_correct + self.q3_is_correct + self.q4_is_correct + self.q5_is_correct
        self.payoff = Constants.point_per_question * self.questions_correct
Пример #8
0
class Player(BasePlayer):

    consent = models.BooleanField()
    tscore = models.IntegerField()
    score = models.IntegerField()
    position = models.StringField()
    resources = models.IntegerField()

    practice = models.IntegerField()


    def vars_for_template(self):

        resources_player_A = self.session.config['resources_player_A']
        resources_player_B = self.session.config['resources_player_B']
        resources_player_C = self.session.config['resources_player_C']
        decision_point = self.session.config['decision_point']

        total_payoff = self.session.config['total_payoff']
        base_fee = self.session.config['base_fee']
        payoff_conversion = self.session.config['payoff_conversion']
        max_bonus = total_payoff * payoff_conversion
        timeout_time = self.session.config['timeout_time']
        timeout_time_minutes = timeout_time / 60
        comprehension_check = self.session.config['comprehension_check']
        incentives = self.session.config['incentives']
        earned = self.session.config['earned']
        slider_time = self.session.config['slider_time']
        grand_coalition = self.session.config['grand_coalition']

        possible_coalitions_A = []
        possible_coalitions_B = []
        possible_coalitions_C = []
        possible_coalitions_all = []

        select_none = self.session.config['select_none']

        if self.subsession.resources_AB >= self.session.config['decision_point']:
            possible_coalitions_A.append('AB')
            possible_coalitions_B.append('AB')
            possible_coalitions_all.append('AB')
        if self.subsession.resources_AC >= self.session.config['decision_point']:
            possible_coalitions_A.append('AC')
            possible_coalitions_C.append('AC')
            possible_coalitions_all.append('AC')
        if self.subsession.resources_BC >= self.session.config['decision_point']:
            possible_coalitions_B.append('BC')
            possible_coalitions_C.append('BC')
            possible_coalitions_all.append('BC')
        if self.subsession.resources_ABC >= self.session.config['decision_point'] and self.session.config[
            'grand_coalition']:
            possible_coalitions_A.append('ABC')
            possible_coalitions_B.append('ABC')
            possible_coalitions_C.append('ABC')
            possible_coalitions_all.append('ABC')

        return {'possible_coalitions_A': possible_coalitions_A,
                'possible_coalitions_B': possible_coalitions_B,
                'possible_coalitions_C': possible_coalitions_C,
                'possible_coalitions_all': possible_coalitions_all,
                'resources_player_A': resources_player_A,
                'resources_player_B': resources_player_B,
                'resources_player_C': resources_player_C,
                'total_payoff': total_payoff,
                'base_fee': base_fee,
                'payoff_conversion': payoff_conversion,
                'select_none':select_none,
                'decision_point':decision_point,
                'max_bonus': max_bonus,
                'timeout_time': timeout_time,
                'timeout_time_minutes': timeout_time_minutes,
                'comprehension_check': comprehension_check,
                'incentives': incentives,
                'earned': earned,
                'slider_time': slider_time,
                'grand_coalition': grand_coalition,
                }

    def slider_field(label):
        return models.IntegerField(min=0,
        max=100,
        widget=widgets.Slider(),
        default = 0,
        label=label,)

    tslider1 = slider_field(False)
    tslider2 = slider_field(False)
    tslider3 = slider_field(False)
    tslider4 = slider_field(False)
    tslider5 = slider_field(False)
    tslider6 = slider_field(False)
    tslider7 = slider_field(False)
    tslider8 = slider_field(False)
    tslider9 = slider_field(False)
    tslider10 = slider_field(False)
    tslider11 = slider_field(False)
    tslider12 = slider_field(False)
    tslider13 = slider_field(False)
    tslider14 = slider_field(False)
    tslider15 = slider_field(False)
    tslider16 = slider_field(False)
    tslider17 = slider_field(False)
    tslider18 = slider_field(False)
    tslider19 = slider_field(False)
    tslider20 = slider_field(False)
    tslider21 = slider_field(False)

    slider1 = slider_field(False)
    slider2 = slider_field(False)
    slider3 = slider_field(False)
    slider4 = slider_field(False)
    slider5 = slider_field(False)
    slider6 = slider_field(False)
    slider7 = slider_field(False)
    slider8 = slider_field(False)
    slider9 = slider_field(False)
    slider10 = slider_field(False)
    slider11 = slider_field(False)
    slider12 = slider_field(False)
    slider13 = slider_field(False)
    slider14 = slider_field(False)
    slider15 = slider_field(False)
    slider16 = slider_field(False)
    slider17 = slider_field(False)
    slider18 = slider_field(False)
    slider19 = slider_field(False)
    slider20 = slider_field(False)
    slider21 = slider_field(False)
Пример #9
0
class Player(BasePlayer):
    def participant_vars_dump(self, page):
        for field in page.form_fields:
            if type(getattr(self, field)) != type(None):
                self.participant.vars[field +'_'+str(self.round_number)] = getattr(self, field)

    #inferred demographic variables
    inferred_gender = models.StringField(
        label = '',
        choices = ['Male','Female','Trans/Non-Binary/Other'],
        )
    inferred_age = models.StringField(
        label = '',
        choices = ['Under 18','18 - 24','25 - 34', '35 - 44','45 - 54', '55 - 64','65 or Older'],
        )
    inferred_orientation = models.StringField(
        label = '',
        choices = ['Heterosexual or Straight', 'Non-heterosexual or Non-straight'],
        )
    inferred_politics = models.IntegerField(
        label = '',
        choices =
        [
        [5, 'Very Conservative'],
        [4, 'Conservative'],
        [3, 'Equally Liberal and Conservative'],
        [2, 'Liberal'],
        [1, 'Very Liberal'],
        ]
        )

    inferred_ally = models.StringField(
        label = '',
        choices = ['Yes', 'No'],
        )

    #confidence variables
    gender_confidence = models.IntegerField(
        label = '',
        choices = [
            [1, 'I chose randomly'],
            [2, 'A little confident'],
            [3, 'Fairly confident'],
            [4, 'Highly confident']
            ]
        )
    age_confidence = models.IntegerField(
        label = '',
        choices = [
            [1, 'I chose randomly'],
            [2, 'A little confident'],
            [3, 'Fairly confident'],
            [4, 'Highly confident']
            ]
        )
    orientation_confidence = models.IntegerField(
        label = '',
        choices = [
            [1, 'I chose randomly'],
            [2, 'A little confident'],
            [3, 'Fairly confident'],
            [4, 'Highly confident']
            ]
        )
    ally_confidence = models.IntegerField(
        label = '',
        choices = [
            [1, 'I chose randomly'],
            [2, 'A little confident'],
            [3, 'Fairly confident'],
            [4, 'Highly confident']
            ]
        )
    politics_confidence = models.IntegerField(
        label = '',
        choices = [
            [1, 'I chose randomly'],
            [2, 'A little confident'],
            [3, 'Fairly confident'],
            [4, 'Highly confident']
            ]
        )

    #explanation variables
    give_explain = models.LongStringField(
        label = '')
    samedifferent_explain = models.LongStringField(
        label = '')

    #own id explanation variables
    id_explain = models.LongStringField(
        label = '')
    icon_explain = models.LongStringField(
        label = '')

    def id_explain_error_message(self,value):
        if len(value)<5:
            return 'Your response to this question must be at least 5 characters long.'

    def icon_explain_error_message(self,value):
        if len(value)<5:
            return 'Your response to this question must be at least 5 characters long.'

    #open ended response
    thoughts = models.LongStringField(
        label ='First of all, what do you think of the study today?')

    #average guesses
    average_guess = models.IntegerField(
        min=0,
        max=100
        )
Пример #10
0
class Group(BaseGroup):
    max_round_num = models.IntegerField()
    new_round_num = models.IntegerField()
Пример #11
0
 def slider_field(label):
     return models.IntegerField(min=0,
     max=100,
     widget=widgets.Slider(),
     default = 0,
     label=label,)
Пример #12
0
class Group(BaseGroup):
    sent_amount_1 = models.IntegerField(
        choices=[0, 1, 2, 3, 4, 5, 6],
        doc="""Amount sent if you are A""",
        label="Si fueras el jugador A, ¿cuánto enviarías al Jugador B?",
    )

    sent_amount_2_1 = models.IntegerField(
        choices=[0, 1, 2, 3],
        doc="""Amount sent if you are B""",
        label="Si fueras el jugador B y recibieras 3 puntos, ¿cuánto enviarías de vuelta al Jugador A?",
    )
    
    sent_amount_2_2 = models.IntegerField(
        choices=[0, 1, 2, 3, 4, 5, 6],
        doc="""Amount sent if you are B""",
        label="Si fueras el jugador B y recibieras 6 puntos, ¿cuánto enviarías de vuelta al Jugador A?",
    )
    
    sent_amount_2_3 = models.IntegerField(
        choices=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
        doc="""Amount sent if you are B""",
        label="Si fueras el jugador B y recibieras 9 puntos, ¿cuánto enviarías de vuelta al Jugador A?",
    )
    
    sent_amount_2_4 = models.IntegerField(
        choices=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
        doc="""Amount sent if you are B""",
        label="Si fueras el jugador B y recibieras 12 puntos, ¿cuánto enviarías de vuelta al Jugador A?",
    )
    
    sent_amount_2_5 = models.IntegerField(
        choices=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
        doc="""Amount sent if you are B""",
        label="Si fueras el jugador B y recibieras 15 puntos, ¿cuánto enviarías de vuelta al Jugador A?",
    )
    
    sent_amount_2_6 = models.IntegerField(
        choices=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18],
        doc="""Amount sent if you are B""",
        label="Si fueras el jugador B y recibieras 18 puntos, ¿cuánto enviarías de vuelta al Jugador A?",
    )

    def sent_amount_2_choices(self):
        return currency_range(c(0), self.sent_amount_1 * Constants.multiplier, c(1))

    def set_payoffs(self):
        
        p1 = self.get_player_by_id(1)
        p2 = self.get_player_by_id(2)

        if self.sent_amount_1 == 0:
            p1.payoff = 10
            p2.payoff = 0
        elif self.sent_amount_1 == 1:
            p1.payoff = Constants.endowment - self.sent_amount_1 + self.sent_amount_2_1
            p2.payoff = self.sent_amount_1 * Constants.multiplier - self.sent_amount_2_1
        elif self.sent_amount_1 == 2:
            p1.payoff = Constants.endowment - self.sent_amount_1 + self.sent_amount_2_2
            p2.payoff = self.sent_amount_1 * Constants.multiplier - self.sent_amount_2_2
        elif self.sent_amount_1 == 3:
            p1.payoff = Constants.endowment - self.sent_amount_1 + self.sent_amount_2_3
            p2.payoff = self.sent_amount_1 * Constants.multiplier - self.sent_amount_2_3
        elif self.sent_amount_1 == 4:
            p1.payoff = Constants.endowment - self.sent_amount_1 + self.sent_amount_2_4
            p2.payoff = self.sent_amount_1 * Constants.multiplier - self.sent_amount_2_4
        elif self.sent_amount_1 == 5:
            p1.payoff = Constants.endowment - self.sent_amount_1 + self.sent_amount_2_5
            p2.payoff = self.sent_amount_1 * Constants.multiplier - self.sent_amount_2_5
        else:
            p1.payoff = Constants.endowment - self.sent_amount_1 + self.sent_amount_2_6
            p2.payoff = self.sent_amount_1 * Constants.multiplier - self.sent_amount_2_6
Пример #13
0
class Player(BasePlayer):

    # add model fields to class player
    # ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    if Constants.certain_choice:
        for j in range(1, Constants.num_choices + 1):
            locals()['choice_' + str(j)] = models.StringField()
        del j
    else:
        for j in range(1, Constants.num_choices):
            locals()['choice_' + str(j)] = models.StringField()
        del j

    random_draw = models.IntegerField()
    choice_to_pay = models.StringField()
    option_to_pay = models.StringField()
    inconsistent = models.IntegerField()
    switching_row = models.IntegerField()

    # set player's payoff
    # ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    def set_payoffs(self):

        # random draw to determine whether to pay the "high" or "low" outcome of the randomly picked lottery
        # ------------------------------------------------------------------------------------------------------------
        self.random_draw = randrange(1,
                                     len(self.participant.vars['mpl_choices']))

        # set <choice_to_pay> to participant.var['choice_to_pay'] determined creating_session
        # ------------------------------------------------------------------------------------------------------------
        self.choice_to_pay = self.participant.vars['mpl_choice_to_pay']

        # elicit whether lottery "A" or "B" was chosen for the respective choice
        # ------------------------------------------------------------------------------------------------------------
        self.option_to_pay = getattr(self, self.choice_to_pay)

        # set player's payoff
        # ------------------------------------------------------------------------------------------------------------
        if self.option_to_pay == 'A':
            self.payoff = Constants.lottery_a_lo
        else:
            if self.random_draw <= self.participant.vars['mpl_index_to_pay']:
                self.payoff = Constants.lottery_b_hi
            else:
                self.payoff = Constants.lottery_b_lo

        # set payoff as global variable
        # ------------------------------------------------------------------------------------------------------------
        self.participant.vars['mpl_payoff'] = self.payoff

    # determine consistency
    # ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    def set_consistency(self):

        n = Constants.num_choices

        # replace A's by 1's and B's by 0's
        self.participant.vars['mpl_choices_made'] = [
            1 if j == 'A' else 0
            for j in self.participant.vars['mpl_choices_made']
        ]

        # check for multiple switching behavior
        for j in range(1, n):
            choices = self.participant.vars['mpl_choices_made']
            self.inconsistent = 1 if choices[j] > choices[j - 1] else 0
            if self.inconsistent == 1:
                break

    # determine switching row
    # ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    def set_switching_row(self):

        # set switching point to row number of first 'B' choice
        if self.inconsistent == 0:
            self.switching_row = sum(
                self.participant.vars['mpl_choices_made']) + 1
Пример #14
0
class Group(DecisionGroup):
    tick_num = models.IntegerField(initial=0)
    interval = models.IntegerField(initial=0)
    x_t = models.FloatField(initial=0)

    # Getters for config values
    def period_length(self):
        return parse_config(
            self.session.config['config_file'])[self.round_number -
                                                1]["period_length"]

    def graph_length(self):
        return parse_config(
            self.session.config['config_file'])[self.round_number -
                                                1]["period_length"]

    def group_play(self):
        return parse_config(
            self.session.config['config_file'])[self.round_number -
                                                1]["group_play"]

    def tick_length(self):
        return parse_config(
            self.session.config['config_file'])[self.round_number -
                                                1]["tick_length"]

    def game_constant(self):
        return parse_config(
            self.session.config['config_file'])[self.round_number -
                                                1]["game_constant"]

    def a_sto(self):
        return parse_config(
            self.session.config['config_file'])[self.round_number - 1]["a_sto"]

    def b_sto(self):
        return parse_config(
            self.session.config['config_file'])[self.round_number - 1]["b_sto"]

    def c_sto(self):
        return parse_config(
            self.session.config['config_file'])[self.round_number - 1]["c_sto"]

    def s_sto(self):
        return parse_config(
            self.session.config['config_file'])[self.round_number - 1]["s_sto"]

    def x_0(self):
        return parse_config(
            self.session.config['config_file'])[self.round_number - 1]["x_0"]

    def P_sto(self):
        return parse_config(
            self.session.config['config_file'])[self.round_number - 1]["P_sto"]

    def R_sto(self):
        return parse_config(
            self.session.config['config_file'])[self.round_number - 1]["R_sto"]

    def treatment(self):
        return parse_config(
            self.session.config['config_file'])[self.round_number -
                                                1]["treatment"]

    def show_button(self):
        return parse_config(
            self.session.config['config_file'])[self.round_number -
                                                1]["show_button"]

    def steps_ahead(self):
        return parse_config(
            self.session.config['config_file'])[self.round_number -
                                                1]["steps_ahead"]

    def num_rounds(self):
        return len(parse_config(self.session.config['config_file']))

    # oTree Redwood method
    def when_all_players_ready(self):
        super().when_all_players_ready()

        # Needed for first tick logic
        self.x_t = None

        emitter = DiscreteEventEmitter(self.tick_length(),
                                       self.period_length(), self, self.tick,
                                       True)
        emitter.start()

    # oTree Redwood tick
    def tick(self, current_interval, interval):
        self.refresh_from_db()

        # For a randomly generated initial uncommment the generate below and the comment the other generate
        self.generate_x_t()

        # Message to channel, Include x_t value for treatment
        msg = {}

        for player in self.get_players():
            playerCode = player.participant.code
            p_code = self.group_decisions[playerCode]
            player.update_payoff(self.x_t, p_code)
            msg[playerCode] = {
                'interval': current_interval * self.tick_length(),
                'value': player.get_error_pay(),
                'payoff': player.get_payoff(),
                'x_t': self.x_t,
                'decision': 1
            }

        # Send message across channel
        self.send('tick', msg)

    # Random value generator using formula in spec
    def generate_x_t(self):
        self.refresh_from_db()
        # First tick logic
        if self.x_t is None:
            print(self.x_t)
            # Set X_0 to value determined by config
            self.x_t = self.c_sto()

            # Always save so database updates user values
            self.save()

        # Not first tick so follow forula specification
        elif not self.group_play():
            self.x_t = ((self.a_sto() * self.x_t) + self.generate_noise())

            # b offset value
            self.x_t += self.b_sto()
        else:
            self.x_t = (self.c_sto() + self.a_sto() *
                        (self.forecast_ave() - self.c_sto()) +
                        self.s_sto() * self.generate_noise())

        # round to .2f
        # self.x_t = round(self.x_t, 2)

        # Always save so database updates user values
        self.tick_num += 1
        self.save()
        return self.x_t

    # Noise generation
    def generate_noise(self):
        # Genrate number on normal distribution using Numpy
        # Mean: 0
        # Std. D: 1
        e_t = np.random.normal(0, 1)

        # Multiply by s value (Determined by config)
        return (self.s_sto() * e_t)

    def forecast_ave(self):
        if self.tick_num < self.steps_ahead():
            return self.c_sto()

        self.refresh_from_db()

        total = 0
        valid = 0

        for player in self.get_players():
            playerCode = player.participant.code
            p_code = self.group_decisions[playerCode]
            if p_code >= 5:
                total += p_code
                valid += 1
                print(p_code)
            # if p_code == 1 or p_code == 0:
            #     total += self.c_sto()
            # else:
            #     total += p_code[1]

        if valid < 1:
            return self.c_sto()

        return total / valid
Пример #15
0
class Player(BasePlayer):
    treat = models.IntegerField()  # Treatments from 1 to 6

    given_group = models.PositiveIntegerField(choices=[
        [1, 'Está fijo y no cambia'],
        [2, 'El computador lo cambia en cada ronda'],
        [3, 'Yo lo puedo cambiar en cada ronda'],
    ],
                                              widget=widgets.RadioSelect)

    appearance = models.PositiveIntegerField(choices=[
        [1, 'Está fija y no cambia'],
        [2, 'El computador la cambia en cada ronda'],
        [3, 'Yo la puedo cambiar en cada ronda al cambiar mi grupo'],
    ],
                                             widget=widgets.RadioSelect)

    label = models.PositiveIntegerField(choices=[
        [1, 'Está fija y no cambia'],
        [2, 'El computador la cambia en cada ronda'],
        [3, 'Yo la puedo cambiar en cada ronda'],
    ],
                                        widget=widgets.RadioSelect)

    cost_change_one = models.PositiveIntegerField(choices=[
        [1, '6 fijos + 2 por 2 personas que no se cambiaron = 10 puntos'],
        [2, '6 fijos + 0 porque todas las personas cambiaron = 6 puntos'],
        [3, '6 fijos + 2 por 1 persona que no se cambió = 8 puntos']
    ],
                                                  widget=widgets.RadioSelect)

    cost_change_none = models.PositiveIntegerField(choices=[
        [1, '6 fijos + 2 por 2 personas que no se cambiaron = 10 puntos'],
        [2, '6 fijos + 0 porque todas las personas cambiaron = 6 puntos'],
        [3, '6 fijos + 2 por 1 persona que no se cambió = 8 puntos']
    ],
                                                   widget=widgets.RadioSelect)

    pay_coord = models.PositiveIntegerField(
        choices=[[1, 'Yo gano 6 y pago el costo de 2 = 4 puntos en total'],
                 [2, 'Yo gano 4 y pago el costo de 2 = 2 puntos en total'],
                 [3, 'Yo gano 0 y pago el costo de 2 = -2 puntos en total']],
        widget=widgets.RadioSelect)

    pay_coord2 = models.PositiveIntegerField(
        choices=[[1, 'Yo gano 6 y pago el costo de 2 = 4 puntos en total'],
                 [2, 'Yo gano 4 y pago el costo de 2 = 2 puntos en total'],
                 [3, 'Yo gano 0 y pago el costo de 2 = -2 puntos en total']],
        widget=widgets.RadioSelect)

    information = models.PositiveIntegerField(choices=[
        [1, 'Ellos pueden ver el grupo que yo elija y mi nueva apariencia'],
        [
            2,
            'Ellos pueden ver el grupo que yo elija y mi apariencia de la Parte {}'
            .format(Constants.part_fixed)
        ],
        [
            3,
            'Ellos no pueden ver el grupo que yo elija sólo mi apariencia de la Parte {}'
            .format(Constants.part_fixed)
        ],
    ],
                                              widget=widgets.RadioSelect)

    def vars_for_template(self):
        return {
            'circles_name': self.participant.vars['circles_name'],
            'triangles_name': self.participant.vars['triangles_name'],
            'circles_label': self.participant.vars['circles_label'],
            'triangles_label': self.participant.vars['triangles_label'],
            'names': len(Constants.names)
        }
Пример #16
0
class Player(BasePlayer):
    name = models.StringField()
    age = models.IntegerField()
Пример #17
0
class Player(BasePlayer):
    appealed = models.BooleanField(label="Would you like to file an appeal?",
                                   choices=[[True, "Yes"], [False, "No"]],
                                   widget=widgets.RadioSelect)
    appeal_granted = models.BooleanField(
        label="What is your judgment?",
        choices=[[
            False, "The estimator and adviser should both receive " +
            str(Constants.appeal_reward_split) + "."
        ],
                 [
                     True, "The estimator should receive " +
                     str(Constants.appeal_reward) +
                     " and the adviser should receive nothing."
                 ]],
        widget=widgets.RadioSelect)

    grid_reward = models.CurrencyField(initial=c(0))
    entered_email = models.BooleanField()
    disclosure = models.BooleanField()

    email = models.StringField(
        label=
        "Please provide your email address. We will send your payment as an Amazon.com gift card to this "
        + "email address within five business days.",
        blank=True,
        initial="")

    consent18 = models.BooleanField(label="I am age 18 or older",
                                    widget=widgets.RadioSelect)
    consentRead = models.BooleanField(
        label="I have read and understand the above information",
        widget=widgets.RadioSelect)
    consentWant = models.BooleanField(
        label=
        "I want to participate in this research and continue with this study",
        widget=widgets.RadioSelect)
    mTurkId = models.StringField(
        label="Please enter your Amazon MTurk ID to continue:", initial="")

    # Demographic questions
    gender = models.IntegerField(label="What is your gender?",
                                 choices=[[1, 'Male'], [2, 'Female']],
                                 widget=widgets.RadioSelect,
                                 blank=True)
    age = models.IntegerField(label="What is your age?",
                              min=18,
                              max=130,
                              blank=True)
    race = models.IntegerField(
        label="What is your race?",
        choices=[[1, 'White'], [2, 'Black, African-American'],
                 [3, 'American Indian or Alaska Native'],
                 [4, 'Asian or Asian-American'], [5, 'Pacific Islander'],
                 [6, 'Some other race']],
        widget=widgets.RadioSelect,
        blank=True)
    education = models.IntegerField(
        label="Please indicate the highest level of education completed.",
        choices=[[1, 'Grammar school'], [2, 'High school or equivalent'],
                 [3, 'Vocational/technical school (2 year)'],
                 [4, 'Some college'], [5, 'College graduate (4 year)'],
                 [6, 'Master\'s degree (MS, etc.)'],
                 [7, 'Doctoral degree (PhD, etc.)'],
                 [8, 'Professional degree (MD, JD, etc.)'], [9, 'Other']],
        widget=widgets.RadioSelect,
        blank=True)
    income = models.IntegerField(
        label="Please indicate your current household income in U.S. dollars",
        choices=[[1, 'Under $10,000'], [2, '$10,000 - $19,999'],
                 [3, '$20,000 - $29,999'], [4, '$30,000 - $39,999'],
                 [5, '$40,000 - $49,999'], [6, '$50,000 - $74,999'],
                 [7, '$75,000 - $99,999'], [8, '$100,000 - $150,000'],
                 [9, 'Over $150,000']],
        widget=widgets.RadioSelect,
        blank=True)

    recommendation = models.IntegerField(min=1, max=900, initial=None)

    estimate = models.IntegerField(min=1, max=900, initial=None)

    get_answer_wrong = models.BooleanField()

    # Final Manipulation checks - No restrictions on answers to players - Role Independent
    manip_final_adviser_payment_question = models.BooleanField(
        widget=widgets.RadioSelect)
    manip_final_estimator_payment_question = models.BooleanField(
        widget=widgets.RadioSelect)
    manip_final_conflict_disclosed_or_not = models.BooleanField(
        widget=widgets.RadioSelect)

    # Initial Manipulation Questions - Players not allowed to proceed unless answered True
    manip_adv_adviser_payment_question = models.BooleanField(
        label=
        "In the dots estimation task, you get a bonus only if the estimator underestimates the true number of solid dots.",
        widget=widgets.RadioSelect)

    manip_adv_estimator_payment_question = models.BooleanField(
        label=
        "In the dots estimation task, the estimator gets a bigger bonus the more accurate his/her estimate is.",
        widget=widgets.RadioSelect)

    manip_adv_payment_scheme_disclosed = models.BooleanField(
        label=
        "Your payment scheme is disclosed to the estimator in the online communication form.",
        widget=widgets.RadioSelect)

    manip_adv_payment_scheme_not_disclosed = models.BooleanField(
        label=
        "Your payment scheme is NOT disclosed to the estimator in the online communication form.",
        widget=widgets.RadioSelect)

    manip_est_estimator_payment_question = models.BooleanField(
        label=
        "In the dots estimation task, you will get a bigger bonus the more accurate your estimate is.",
        widget=widgets.RadioSelect)

    manip_est_judge_payment_question = models.BooleanField(
        label=
        "The estimator will get a bigger bonus the more accurate their estimate is.",
        widget=widgets.RadioSelect)

    manip_adv_judge_payment_question = models.BooleanField(
        label=
        "The adviser will get a bigger bonus the more the estimator overestimated the true number of solid dots.",
        widget=widgets.RadioSelect)

    manip_judge_disclosure_question = models.StringField(
        label=
        "Did estimators know that the advisers would get a bonus if they overestimated?",
        widget=widgets.RadioSelect,
        choices=[
            "No, they didn’t", "Yes, they did",
            "Some estimators were told and some were not told"
        ])

    comment = models.LongStringField(
        label="Do you have any comments for the researchers? (Optional)",
        blank=True)

    estimator_appeal_question = models.LongStringField(blank=True)

    judge_bonus_awarded_clarify = judge_bonus_field(True)
    judge_bonus_not_awarded_clarify = judge_bonus_field(False)

    # Blame Questions - Estimator
    blame_EST_I_blame_myself_for_my_guess = make_Likert_agreement(
        "I blame myself for my guess.")
    blame_EST_I_blame_the_adviser_for_my_guess = make_Likert_agreement(
        "I blame the adviser for my guess.")
    blame_EST_I_have_a_legitimate_grievance_against_the_adviser = make_Likert_agreement(
        "I have a legitimate grievance against the adviser.")
    blame_EST_I_have_a_strong_case_if_I_choose_to_pursue_an_appeal = make_Likert_agreement(
        "I have a strong case if I choose to pursue an appeal.")
    blame_EST_I_believe_that_others_would_rule_in_my_favor = make_Likert_agreement(
        "I believe that others would rule in my favor on an appeal.")
    blame_EST_The_adviser_treated_me_fairly = make_Likert_agreement(
        "The adviser treated me fairly.")
    blame_EST_I_was_mistreated_by_the_adviser = make_Likert_agreement(
        "I was mistreated by the adviser.")
    blame_EST_I_deserve_to_receive_the_full_bonus = make_Likert_agreement(
        "I deserve to receive the full bonus of $2.00.")

    # Blame Questions - Judge
    blame_JUDGE_I_blame_the_estimator_for_their_guess = make_Likert_agreement(
        "I blame the estimator for their guess.")
    blame_JUDGE_I_blame_the_adviser_for_the_estimators_guess = make_Likert_agreement(
        "I blame the adviser for the estimator's guess.")
    blame_JUDGE_estimator_has_legitimate_grievance_against_adviser = make_Likert_agreement(
        "The estimator has a legitimate grievance against the adviser.")
    blame_JUDGE_estimator_has_a_strong_case_to_pursue_an_appeal = make_Likert_agreement(
        "The estimator has a strong case if he or she choses to pursue an appeal."
    )
    blame_JUDGE_I_believe_others_would_rule_in_estimators_favor = make_Likert_agreement(
        "I believe that others would rule in the estimator's favor on an appeal."
    )
    blame_JUDGE_The_adviser_treated_the_estimator_fairly = make_Likert_agreement(
        "The adviser treated the estimator fairly.")
    blame_JUDGE_The_estimator_was_mistreated_by_the_adviser = make_Likert_agreement(
        "The estimator was mistreated by the adviser.")
    blame_JUDGE_The_estimator_deserves_to_receive_the_full_bonus = make_Likert_agreement(
        "The estimator deserves to receive the full bonus of $2.00.")

    # 6 Player Group - 1 triplet for disclosure and 1 triplet for non-disclosure conditions

    def role(self):
        if 1 <= self.id_in_group <= 2:
            return 'adviser'
        elif 3 <= self.id_in_group <= 4:
            return 'estimator'
        elif 5 <= self.id_in_group <= 6:
            return 'judge'

    def matched_adviser(self):
        id = self.id_in_group - 1
        if self.is_adviser():
            return self
        elif self.is_estimator():
            return self.group.get_players()[id - 2]
        else:
            return self.group.get_players()[id - 4]

    def matched_estimator(self):
        id = self.id_in_group - 1
        if self.is_estimator():
            return self
        elif self.is_adviser():
            return self.group.get_players()[id + 2]
        else:
            return self.group.get_players()[id - 2]

    def matched_judge(self):
        id = self.id_in_group - 1
        if self.is_judge():
            return self
        elif self.is_adviser():
            return self.group.get_players()[id + 4]
        else:
            return self.group.get_players()[id + 2]

    def get_correct_answer(self):
        return self.group.correct_answer

    def is_adviser(self):
        return self.id_in_group in list(range(1, 3))

    def is_estimator(self):
        return self.id_in_group in list(range(3, 5))

    def is_judge(self):
        return self.id_in_group in list(range(5, 7))

    def get_recommendation(self):
        return self.matched_adviser().recommendation

    def get_estimate(self):
        return self.matched_estimator().estimate

    def is_timed_out(self):
        return self.participant.vars['expiry'] - time.time() <= 3

    def number_off(self):
        return self.matched_estimator().estimate - self.group.correct_answer

    # Calculates rewards based on the adviser's recommendation and estimator's estimate, then stores them per player
    # in grid_reward.
    def calculate_grid_rewards(self):
        adviser = self.matched_adviser()
        estimator = self.matched_estimator()

        print('Calculate Grid Rewards - before', ' adviser: ', adviser.payoff,
              ' estimator: ', estimator.payoff)
        print('Calculate ParticipantPayoff Rewards - before', ' adviser: ',
              adviser.participant.payoff, ' estimator: ',
              estimator.participant.payoff)

        if estimator.estimate < (self.group.correct_answer - 40):
            estimator.grid_reward = Constants.estimator_bonus_less_than_neg_40  # Nothing
            adviser.grid_reward = Constants.adviser_bonus_less_than_neg_40  # Nothing
        elif (self.group.correct_answer -
              40) <= estimator.estimate <= (self.group.correct_answer - 31):
            estimator.grid_reward = Constants.estimator_bonus_within_neg_40_and_31
            adviser.grid_reward = Constants.adviser_bonus_within_neg_40_and_31  # Nothing
        elif (self.group.correct_answer -
              30) <= estimator.estimate <= (self.group.correct_answer - 21):
            estimator.grid_reward = Constants.estimator_bonus_within_neg_30_and_21
            adviser.grid_reward = Constants.adviser_bonus_within_neg_30_and_21  # Nothing
        elif (self.group.correct_answer -
              20) <= estimator.estimate <= (self.group.correct_answer - 11):
            estimator.grid_reward = Constants.estimator_bonus_within_neg_20_and_11
            adviser.grid_reward = Constants.adviser_bonus_within_neg_20_and_11  # Nothing
        elif (self.group.correct_answer -
              10) <= estimator.estimate <= (self.group.correct_answer):
            estimator.grid_reward = Constants.estimator_bonus_within_neg_10_and_1
            adviser.grid_reward = Constants.adviser_bonus_within_neg_10_and_1  # Nothing
        elif (self.group.correct_answer +
              1) <= estimator.estimate <= (self.group.correct_answer + 10):
            estimator.grid_reward = Constants.estimator_bonus_within_0_and_10
            adviser.grid_reward = Constants.adviser_bonus_within_0_and_10
        elif (self.group.correct_answer +
              11) <= estimator.estimate <= (self.group.correct_answer + 20):
            estimator.grid_reward = Constants.estimator_bonus_within_11_and_21
            adviser.grid_reward = Constants.adviser_bonus_within_11_and_21
        elif (self.group.correct_answer +
              21) <= estimator.estimate <= (self.group.correct_answer + 30):
            estimator.grid_reward = Constants.estimator_bonus_within_21_and_30
            adviser.grid_reward = Constants.adviser_bonus_within_21_and_30
        elif (self.group.correct_answer +
              31) <= estimator.estimate <= (self.group.correct_answer + 40):
            estimator.grid_reward = Constants.estimator_bonus_within_31_and_40
            adviser.grid_reward = Constants.adviser_bonus_within_31_and_40
        elif estimator.estimate > (self.group.correct_answer + 40):
            estimator.grid_reward = Constants.estimator_bonus_greater_than_40  # Nothing
            adviser.grid_reward = Constants.adviser_bonus_greater_than_40

        adviser.payoff = adviser.grid_reward
        estimator.payoff = estimator.grid_reward
        print('Calculate Grid Rewards - after', ' adviser: ', adviser.payoff,
              ' estimator: ', estimator.payoff)
        print('Calculate ParticipantPayoff Rewards - after', ' adviser: ',
              adviser.participant.payoff, ' estimator: ',
              estimator.participant.payoff)

    def recalculate_payOffs_with_appeal(self, is_appeal_success):
        adviser = self.matched_adviser()
        estimator = self.matched_estimator()
        judge = self.matched_judge()

        print('In Recalculate. Payoffs - before', ' adviser: ', adviser.payoff,
              ' estimator: ', estimator.payoff, ' judge: ',
              judge.participant.payoff)
        print('In Recalculate. Participant Payoffs - before', ' adviser: ',
              adviser.participant.payoff, ' estimator: ',
              estimator.participant.payoff, ' judge: ',
              judge.participant.payoff)

        if is_appeal_success:
            adviser.payoff = adviser.grid_reward
            estimator.payoff = estimator.grid_reward + \
                Constants.appeal_reward - Constants.appeal_cost
        else:
            adviser.payoff = adviser.grid_reward + Constants.appeal_reward_split
            estimator.payoff = estimator.grid_reward + \
                Constants.appeal_reward_split - Constants.appeal_cost

        judge.payoff = Constants.appeal_cost

        print('In Recalculate. Payoffs - after', ' adviser: ', adviser.payoff,
              ' estimator: ', estimator.payoff, ' judge: ',
              judge.participant.payoff)
        print('In Recalculate. Participant Payoffs - after', ' adviser: ',
              adviser.participant.payoff, ' estimator: ',
              estimator.participant.payoff, ' judge: ',
              judge.participant.payoff)

    # Set Default Values for Recommendation and Estimate in times of unexpected failures in adviser and Estimator rounds respectively
    def prep_before_decision(self):
        if self.is_estimator() or self.is_judge():
            if self.matched_adviser(
            ).recommendation is None or self.matched_adviser(
            ).recommendation == 0:
                self.matched_adviser().recommendation = self.group.correct_answer + \
                    (92 if self.disclosure else 28)
                print('Prep Recommendation',
                      self.matched_adviser().recommendation)
        if self.is_judge():
            if self.matched_estimator(
            ).estimate is None or self.matched_estimator().estimate == 0:
                self.matched_estimator().estimate = self.group.correct_answer + \
                    (46 if self.disclosure else 14)
                self.calculate_grid_rewards()
                print('Prep Estimate', self.matched_estimator().estimate)

    # Set Default Data for whole triplet group - for situations like timeout
    def set_timeout_data(self):
        if self.is_adviser():
            if self.recommendation is None or self.recommendation == 0:
                self.recommendation = self.group.correct_answer + \
                    (92 if self.disclosure else 28)
        elif self.is_estimator():
            if self.estimate is None or self.estimate == 0:
                self.estimate = self.group.correct_answer + \
                    (46 if self.disclosure else 14)
        elif self.is_judge():
            if self.matched_estimator().appealed:
                self.recalculate_payOffs_with_appeal(False)
Пример #18
0
class Player(BasePlayer):
    R1 = models.IntegerField()
    Y1 = models.IntegerField()
    G1 = models.IntegerField()
    Accuracy1 = models.IntegerField()

    R2 = models.IntegerField()
    Y2 = models.IntegerField()
    G2 = models.IntegerField()

    R3 = models.IntegerField()
    Y3 = models.IntegerField()
    G3 = models.IntegerField()

    R4 = models.IntegerField()
    Y4 = models.IntegerField()
    G4 = models.IntegerField()

    R5 = models.IntegerField()
    Y5 = models.IntegerField()
    G5 = models.IntegerField()

    R6 = models.IntegerField()
    Y6 = models.IntegerField()
    G6 = models.IntegerField()

    R7 = models.IntegerField()
    Y7 = models.IntegerField()
    G7 = models.IntegerField()

    R8 = models.IntegerField()
    Y8 = models.IntegerField()
    G8 = models.IntegerField()

    R9 = models.IntegerField()
    Y9 = models.IntegerField()
    G9 = models.IntegerField()

    R10 = models.IntegerField()
    Y10 = models.IntegerField()
    G10 = models.IntegerField()

    isGray1 = models.BooleanField()
    R1task2 = models.IntegerField()
    Y1task2 = models.IntegerField()
    G1task2 = models.IntegerField()
    Accuracy1task2 = models.IntegerField()


#This class is for out slider
#class Slider(BaseSlider):
#	player = ForeignKey(Player)
Пример #19
0
def get_conceal():
    return models.IntegerField(choices=Constants.choice_arr,
                               blank=True,
                               label="")
Пример #20
0
class Group(BaseGroup):

    # 人か機械の選択 1.人 2.機械
    player_select1 = models.IntegerField(initial=2)
    player_select2 = models.IntegerField(initial=2)

    # プレイヤー1が人に送る
    Sab = models.CurrencyField(
        # initial=0,
        min=0, max=Constants.endowment,
        doc="""Amount sent by P1""",
    )

    # プレイヤー1が機械に送る
    Sam = models.CurrencyField(
        # initial=0,
        min=0, max=Constants.endowment,
        doc="""Amount sent by P1""",
    )

    # プレイヤー2が人に返す
    Rba = models.CurrencyField(
        # initial=0,
        doc="""Amount sent back by P1""",
        min=c(0),
    )

    # プレイヤー2が機械に返す
    Rbm = models.CurrencyField(
        # initial=0,
        doc="""Amount sent back by P1""",
        min=c(0),
    )

    # CPUが送る
    Smb = models.CurrencyField()

    def set_smb(self):
        self.Smb = c(Constants.endowment * normal(0.502, 0.124))
        if self.Smb > 1000:
            self.Smb = c(1000)
        if self.Smb < 0:
            self.Smb = c(0)

    # CPUが送り返す
    rrand = models.CurrencyField()

    def b(self):
        self.rrand = normal(0.372, 0.114)
        if self.rrand > 1:
            self.rrand = 1
        if self.rrand < 0:
            self.rrand = 0
        return self.rrand

    Rma = models.CurrencyField()

    # 最終獲得値
    Ga1 = models.CurrencyField()
    Ga2 = models.CurrencyField()
    Ga3 = models.CurrencyField()
    Gb1 = models.CurrencyField()
    Gb2 = models.CurrencyField()
    Gb3 = models.CurrencyField()

    def set_payoffs(self):
        p1 = self.get_player_by_id(1)
        p2 = self.get_player_by_id(2)
        if self.Sab is None:
            self.Sab = c(0)
        if self.Sam is None:
            self.Sam = c(0)
        if self.Rba is None:
            self.Rba = c(0)
        if self.Rbm is None:
            self.Rbm = c(0)
        self.Rma = self.b() * self.Sam * Constants.multiplier
        # Y(a)
        p1.payoff = Constants.endowment - self.Sab + self.Rma
        # X(a)
        p2.payoff = self.Sab * Constants.multiplier - self.Rma
        self.Ga1 = Constants.endowment - self.Sab + self.Rba
        self.Ga2 = Constants.endowment - self.Sam + self.Rma
        self.Ga3 = Constants.endowment - self.Smb + self.Rbm
        self.Gb1 = self.Sab * Constants.multiplier - self.Rba
        self.Gb2 = self.Smb * Constants.multiplier - self.Rbm
        self.Gb3 = self.Sam * Constants.multiplier - self.Rma
Пример #21
0
class Player(BasePlayer):
    sm_1 = models.IntegerField(
        label="",
        choices=range(10,100),
        blank=True,
    )

    sm_2 = models.IntegerField(
        label="처음 흡연하게 된 가장 큰 동기는 무엇이었습니까?",
        choices=Constants.sm_2_choices,
        widget=widgets.RadioSelect,
        blank=True,
    )

    sm_2_op = models.StringField(
        label="직접입력",
        blank=True,
    )

    sm_3_times = models.IntegerField(
        label="",
        choices=range(0,100),
        blank=True,
    )

    sm_3_mins = models.IntegerField(
        label="",
        choices=range(0,100),
        blank=True,
    )
    sm_3_1_1 = models.IntegerField(
        label="",
        choices=range(1,101),
        blank=True,
    )

    sm_3_1_2 = models.IntegerField(
        label="",
        choices=range(1,101),
        blank=True,
    )
    sm_4_1 = models.BooleanField(
        label="과거에 금연을 시도한 적 있습니까?",
        choices=Constants.BINARY_CHOICES,
        widget=widgets.RadioSelectHorizontal,
        blank=True,
    )

    sm_4_2 = models.IntegerField(
        label="",
        choices=range(1,100),
        blank=True,
    )

    sm_4_3_years = models.IntegerField(
        label="",
        choices=range(0,60),
        blank=True,
    )

    sm_4_3_months = models.IntegerField(
        label="",
        choices=range(0,13),
        blank=True,
    )

    sm_4_3_days = models.IntegerField(
        label="",
        choices=range(1,31),
        blank=True,

    )

    sm_4_4 = models.IntegerField(
        label="금연을 시도하게 된 가장 큰 동기는 무엇이었습니까?",
        choices=Constants.sm_4_4_choices,
        widget=widgets.RadioSelect,
        blank=True,
    )

    sm_4_4_op = models.StringField(
        label="직접입력:",
        blank=True,
    )

    sm_4_5 = models.LongStringField(
        label="",
        blank=True,
    )

    sm_4_6 = models.IntegerField(
        label="현재까지 한 번도 금연을 시도하지 않은 가장 큰 이유는 무엇입니까?",
        choices=Constants.sm_4_6_choices,
        widget=widgets.RadioSelect,
        blank=True,
    )

    sm_4_6_op = models.StringField(
        label="직접입력:",
        blank=True,
    )

    sm_5_1 = models.IntegerField(
        label="하루에 보통 몇 개비나 피우십니까?",
        choices=Constants.sm_5_1_choices,
        widget=widgets.RadioSelectHorizontal,
        blank=True,
    )

    sm_5_2 = models.IntegerField(
        label="아침에 일어나서 얼마 만에 첫 담배를 피우십니까?",
        choices=Constants.sm_5_2_choices,
        widget=widgets.RadioSelectHorizontal,
        blank=True,
    )

    sm_5_3 = models.BooleanField(
        label="금연구역(도서관, 극장, 병원 등)에서 담배를 참기가 어렵습니까?",
        choices=Constants.BINARY_CHOICES,
        widget=widgets.RadioSelectHorizontal,
        blank=True,
    )

    sm_5_4 = models.IntegerField(
        label="하루 중 담배 맛이 가장 좋을 때는 언제입니까?",
        choices=Constants.sm_5_4_choices,
        widget=widgets.RadioSelectHorizontal,
        blank=True,
    )

    sm_5_5 = models.BooleanField(
        label="오후와 저녁 시간보다 오전 중에 담배를 더 자주 피우십니까?",
        choices=Constants.BINARY_CHOICES,
        widget=widgets.RadioSelectHorizontal,
        blank=True,
    )

    sm_5_6 = models.BooleanField(
        label="몸이 아파 하루 종일 누워 있을 때에도 담배를 피우십니까?",
        choices=Constants.BINARY_CHOICES,
        widget=widgets.RadioSelectHorizontal,
        blank=True,
    )

    # sm_6_1_1 = models.IntegerField(
    #         label="",
    #     )
    #
    # sm_6_1_2 = models.IntegerField(
    #     label="",
    # )

    sm_6_2_1 =  models.IntegerField(
        label="나의 직속 상사",
        widget=widgets.RadioSelectHorizontal,
        choices=nonsmoker_models.Constants.IS_SMOKER_CHOICES,
        blank=True,
    )

    sm_6_2_2 = models.IntegerField(
        label="나의 소속부서 총괄 책임자",
        widget=widgets.RadioSelectHorizontal,
        choices=nonsmoker_models.Constants.IS_SMOKER_CHOICES,
        blank=True,
    )

    sm_6_2_3 = models.IntegerField(
        label="나의 소속기관의 최고경영자",
        widget=widgets.RadioSelectHorizontal,
        choices=nonsmoker_models.Constants.IS_SMOKER_CHOICES,
        blank=True,
    )

    sm_6_3 = models.IntegerField(
        label="귀하는 근무시간 중 흡연시 동료나 상사 등 다른 사람과 같이 피우는 경우가 10번 중 몇 번 정도인지 아래 숫자를 선택해주십시오.",
        choices=range(0,11),
        widget=widgets.RadioSelectHorizontal,
        blank=True,
    )
Пример #22
0
class Player(BasePlayer):

    treatment = models.StringField()

    age = models.StringField(
        choices = [['a','18岁及以下'],['b','19-22岁'],['c','23-25岁'],['d','26-29岁'],['e','30-39岁'],['f','40岁以上']],
        label='2. 您的年龄区间',
        widget=widgets.RadioSelect,
    )

    gender = models.StringField(
        choices=[['Male','男'], ['Female', '女']],
        label='1. 您的性别',
        widget=widgets.RadioSelect
    )
    
    occupation = models.StringField(
        choices=[['Student','学生'], ['No', '其他']],
        label='3. 您的身份',
        widget=widgets.RadioSelect
    )

    education = models.StringField(
        choices=[['1','高中及以下'], ['2', '大专'],['3','本科'],['4','研究生'],['5','博士及以上']],
        label='4. 您的最高学历',
        widget=widgets.RadioSelect
    )

    income = models.StringField(
        choices=[['1','少于1000元'], ['2', '1000-1999元'],['3','2000-2999元'],['4','3000-4999元'],['5','5000-9999元'],['6','1万元及以上']],
        label='5. 您每月可支配收入区间',
        widget=widgets.RadioSelect
    )

    inc = models.IntegerField(label='6. 请估算您每月可支配收入平均值',min=0,max=10001,widget=widgets.Slider)

    hometown = models.StringField(
        choices=[['1','一线城市(北上广深)'], ['2', '新一线城市(可参考本页底部小贴士)'],['3','新二线城市(可参考本页底部小贴士)'],['4','三线及以下']],
        label='7. 您家乡所在城市梯次',
        widget=widgets.RadioSelect
    )

    location = models.StringField(
        choices=[['1','一线城市(北上广深)'], ['2', '新一线城市(可参考本页底部小贴士)'],['3','新二线城市(可参考本页底部小贴士)'],['4','三线及以下']],
        label='8. 您常住地所在城市梯次',
        widget=widgets.RadioSelect
    )

    necessity = models.StringField( 
        label = "1. 请选择您最常购买的三件商品",
        widget = django_widgets.CheckboxSelectMultiple(
            choices = [
                ['1.png', "洗护用品(洗发水/沐浴露/身体乳等)"], 
                ['2.png', "肉类(猪/牛/羊/鱼/禽等)"], 
                ['3.png', "蛋类(鸡/鸭/鹅等)"],
                ['4.png', "粮食类(米/面/粉/红薯/玉米等)"], 
                ['5.png', "奶制品(一箱牛奶/酸奶等)"], 
                ['6.png', "贴身衣物(内衣/内裤/袜子等)"], 
                ['7.png', "T恤(长袖/短袖等)"], 
                ['8.png', "水果(苹果/梨/香蕉等)"],
                ['9.png', "蔬菜(白菜/生菜/西红柿等)"], 
                ['10.png', "零食(薯片/饼干/坚果等)"]
            ]
        )
    )
    '''
    def necessity_error_message(self,value):
        if len(value.split(',')) != 3:
            return "请务必选择三件"
    '''
    
    comfort = models.StringField(
        label = "2. 请选择你最常购买的三件商品",
        widget = django_widgets.CheckboxSelectMultiple(
            choices = [
                ['11.png', "3C配件(耳机/硬盘/数位板等)"], 
                ['12.png', "鞋子(运动鞋/休闲鞋/高跟鞋等)"], 
                ['13.png', "包包(书包/挎包/手提包等)"],
                ['14.png', "高端护肤品(眼霜/水乳套装/面膜等)"], 
                ['15.png', "高端化妆品(口红/粉底/遮瑕等)"], 
                ['16.png', "衣服(卫衣/卫裤/西装等)"], 
                ['17.png', "游戏装备(数字游戏/游戏装备等)"], 
                ['18.png', "小型家电(烤箱/咖啡机/音响等)"],
                ['19.png', "组装小型家具(组装式书架/晾衣架等)"], 
                ['20.png', "高端文具(钢笔/墨水/画板等)"],       
            ]
        )
    )

    '''
    def comfort_error_message(self,value):
        if len(value.split(',')) != 3:
            return "请务必选择三件"
    '''

    n1 = models.IntegerField(widget=django_widgets.HiddenInput())
    n2 = models.IntegerField(widget=django_widgets.HiddenInput())
    n3 = models.IntegerField(widget=django_widgets.HiddenInput())

    c1 = models.IntegerField(widget=django_widgets.HiddenInput())
    c2 = models.IntegerField(widget=django_widgets.HiddenInput())
    c3 = models.IntegerField(widget=django_widgets.HiddenInput())

    valid = models.IntegerField(widget=django_widgets.HiddenInput())

    attention = models.StringField(
        choices=[['A','A. Stephen'], ['B', 'B. Cindy'],['C','C. Jesse'], ['D','D. Judy']],
        label='请在下列选项中选择S开头的单词',
        widget=widgets.RadioSelect
    )

    valida = models.IntegerField(widget=django_widgets.HiddenInput())

    na1 = models.IntegerField()
    na2 = models.IntegerField()
    na3 = models.IntegerField()

    ca1 = models.IntegerField()
    ca2 = models.IntegerField()
    ca3 = models.IntegerField()
Пример #23
0
class Player(BasePlayer):
    LS_treatment = models.StringField(blank=True)
    LS_Dtotaltime = models.FloatField(
        doc="The total (raw) time elapsed for all Decision-pages.")
    LS_Dtotalfocustime = models.FloatField(
        doc="The total focus time elapsed for all Decision-pages.")
    LS_Dtotalunfocustime = models.FloatField(
        doc="The total unfocus time elapsed for all Decision-pages.")
    LS_Dtotalfocusevents = models.FloatField(
        doc="The total focus off events for all Decision-pages.")
    LS_Rtotaltime = models.FloatField(
        doc="The total (raw) time elapsed for all Results-pages.")
    LS_Rtotalfocustime = models.FloatField(
        doc="The total focus time elapsed for all Results-pages.")
    LS_Rtotalunfocustime = models.FloatField(
        doc="The total unfocus time elapsed for all Results-pages.")
    LS_Rtotalfocusevents = models.FloatField(
        doc="The total focus off events for all Results-pages.")
    LS_YEtotaltime = models.FloatField(
        doc=
        "The total (raw) time elapsed for all Year-End-Summary (Report)-pages."
    )
    LS_YEtotalfocustime = models.FloatField(
        doc=
        "The total focus time elapsed for all Year-End-Summary (Report)-pages."
    )
    LS_YEtotalunfocustime = models.FloatField(
        doc=
        "The total unfocus time elapsed for all Year-End-Summary (Report)-pages."
    )
    LS_YEtotalfocusevents = models.FloatField(
        doc=
        "The total focus off events for all Year-End-Summary (Report)-pages.")
    LS_overallprofit = models.CurrencyField(
        doc="Total profit from all periods in points excl. show-up fee")
    LS_overallpayoffrealworld = models.CurrencyField(
        doc="Total profit incl. show-up fee all periods")
    LS_finloc = models.IntegerField(doc="Location in final period")
    LS_finprofit = models.CurrencyField(doc="Profit in final period")
    LS_maxprofit = models.CurrencyField(
        doc="Highest profit over all 20 rounds")
    LS_maxexpphase = models.IntegerField(
        doc=
        "Longest duration of an exploration phase. An exploration phase starts "
        "when subjects choose a location other than the default location "
        "suggested by the previous manager. An explorative phase is defined as "
        "ending when a subject switches back to the default location or when a "
        "subject does not change location and lemonade color and also does not "
        "change lemon content, sugar content and price by more than 0.25 units. "
        "All that is adapted 1:1 from Ederer&Manso.  ")
    LS_durexpphase = models.IntegerField(
        doc="Total duration of exploration phases, that is the sum of periods a "
        "subject explored. See above for defintion of exp phase.")
    LS_locnotdefault = models.IntegerField(
        doc="Count of chosen non-default (=non-Business) locations.")
    LS_stdvsugar = models.FloatField(
        doc="The standard deviation for sugar choices.")
    LS_stdvlemon = models.FloatField(
        doc="The standard deviation for lemon choices.")
    LS_stdvprice = models.FloatField(
        doc="The standard deviation for price choices.")
    LS_stdvprofit = models.CurrencyField(
        doc="The standard deviation of subject-specific payoffs.")
    LS_stdv3con = models.FloatField(
        doc=
        "The average subject-specific standard deviation of strategy choices for the three continuous variables."
    )
    LS_locnotdefaulth1 = models.IntegerField(
        doc="Count of chosen non-default (=non-Business) locations round 1-10."
    )
    LS_stdvsugarh1 = models.FloatField(
        doc="The standard deviation for sugar choices, round 1-10.")
    LS_stdvlemonh1 = models.FloatField(
        doc="The standard deviation for lemon choices, round 1-10.")
    LS_stdvpriceh1 = models.FloatField(
        doc="The standard deviation for price choices, round 1-10.")
    LS_stdvprofith1 = models.CurrencyField(
        doc="The standard deviation of subject-specific payoffs, round 1-11.")
    LS_stdv3conh1 = models.FloatField(
        doc=
        "The average subject-specific standard deviation for the three continuous variables, round 1-10."
    )
    LS_locnotdefaulth2 = models.IntegerField(
        doc="Count of chosen non-default (=non-Business) locations round 10-20."
    )
    LS_stdvsugarh2 = models.FloatField(
        doc="The standard deviation for sugar choices, round 11-20.")
    LS_stdvlemonh2 = models.FloatField(
        doc="The standard deviation for lemon choices, round 11-20.")
    LS_stdvpriceh2 = models.FloatField(
        doc="The standard deviation for price choices, round 11-20.")
    LS_stdv3conh2 = models.FloatField(
        doc=
        "The average subject-specific standard deviation for the three continuous variables, round 11-20."
    )
    LS_stdvprofith2 = models.CurrencyField(
        doc="The standard deviation of subject-specific payoffs, round 11-20.")
    LS_report = models.LongStringField(
        doc="Text report, summary of all 4 reports (period 4, 8, 12, 16).")
    LS_reportlength = models.IntegerField(
        doc="total length of text reports of all four reporting periods.")
Пример #24
0
 def investmentsag(self):
     investmentsag = {}
     for i in range(1, self.group.num_players() + 1):
         investmentsag[i] = models.IntegerField(min=0, blank=True, initial=0) #investment in player 1
     return investmentsag
Пример #25
0
class Player(BasePlayer):
    def role(self):
        if self.id_in_group == 1:
            return 'player1'
        else:
            return 'player2'

    def get_partner(self):
        return self.get_others_in_group()[0]

    def get_partner_name(self):
        return self.get_others_in_group()[0].first_name

    def get_code(self):
        code = ""
        if not self.timed_out:
            code = "movies" + str(randint(1000, 9999))
        else:
            code = "timeout" + str(randint(1000, 9999))
        self.mturkCompletitionCode = code
        return code

    selectedMovie = models.StringField(initial="")

    isSelecting = models.BooleanField()

    first_name = models.StringField(label="What is your first name?",
                                    initial="")

    mturkId = models.StringField(label="What is your mturk ID?", initial="")

    mturkCode = models.StringField()

    mturkCompletitionCode = models.StringField(initial="")

    timed_out = models.BooleanField(initial=False)

    madeFinalDecision = models.BooleanField()

    manip_question = models.StringField(
        label="In this study, what were you instructed to do?",
        widget=widgets.RadioSelect,
        choices=[
            "Choose the movie that I personally would enjoy the most",
            "Choose the movie that I think my partner would enjoy the most"
        ])

    satisfied_trailer = models.IntegerField(
        label=
        "How satisfied are you with the choice you came to with your partner?",
        choices=[[1, "1 (Very Unsatisfied)"], [2, "2"], [3, "3"], [4, "4"],
                 [5, "5"], [6, "6"], [7, "7 (Very Satisfied)"]],
        widget=widgets.RadioSelect,
    )

    satisfied_process = models.IntegerField(
        label=
        "How satisfied are you with the process by which you and your partner chose the movie trailer?",
        choices=[[1, "1 (Very Unsatisfied)"], [2, "2"], [3, "3"], [4, "4"],
                 [5, "5"], [6, "6"], [7, "7 (Very Satisfied)"]],
        widget=widgets.RadioSelect,
    )

    satisfied_treated = models.IntegerField(
        label=
        "How satisfied are you with how you were treated by your partner?",
        choices=[[1, "1 (Very Unsatisfied)"], [2, "2"], [3, "3"], [4, "4"],
                 [5, "5"], [6, "6"], [7, "7 (Very Satisfied)"]],
        widget=widgets.RadioSelect,
    )

    willing_to = models.IntegerField(
        label=
        "How willing would you be to make a decision with this partner again in the future?",
        choices=[[1, "1 (Very Unsatisfied)"], [2, "2"], [3, "3"], [4, "4"],
                 [5, "5"], [6, "6"], [7, "7 (Very Satisfied)"]],
        widget=widgets.RadioSelect,
    )

    partner_experience = models.LongStringField(
        label="Explain how your experience with your partner was:", )

    strategy = models.LongStringField(
        label="Explain what your strategy was in selecting a movie trailer:", )

    rate_trailer = models.IntegerField(
        label="Please rate how much you liked the trailer",
        choices=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
        widget=widgets.RadioSelect,
    )

    likely_watch = models.IntegerField(
        label="how likely are you to watch the movie?",
        choices=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
        widget=widgets.RadioSelect,
    )

    # Demographic questions
    gender = models.IntegerField(label="What is your gender?",
                                 choices=[[1, 'Male'], [2, 'Female'],
                                          [3, 'Other']],
                                 widget=widgets.RadioSelect,
                                 blank=True)
    age = models.IntegerField(label="how old are you?",
                              min=18,
                              max=130,
                              blank=True)
    race = models.IntegerField(
        label="What is your race?",
        choices=[[1, 'White'], [2, 'Black, African-American'],
                 [3, 'American Indian or Alaska Native'],
                 [4, 'Asian or Asian-American'], [5, 'Pacific Islander'],
                 [6, 'Some other race']],
        widget=widgets.RadioSelect,
        blank=True)

    education = models.IntegerField(
        label="Please indicate the highest level of education completed.",
        choices=[[1, 'Grammar school'], [2, 'High school or equivalent'],
                 [3, 'Vocational/technical school (2 year)'],
                 [4, 'Some college'], [5, 'College graduate (4 year)'],
                 [6, 'Master\'s degree (MS, etc.)'],
                 [7, 'Doctoral degree (PhD, etc.)'],
                 [8, 'Professional degree (MD, JD, etc.)'], [9, 'Other']],
        widget=widgets.RadioSelect,
        blank=True)

    comment = models.LongStringField(
        label="Do you have any comments for the researchers? (Optional)",
        blank=True)
Пример #26
0
 def return_percentage(self):
     return_amounts = {}
     for i in range(1, self.group.num_players() + 1):
         return_amounts[i] = models.IntegerField(min=0, blank=True, initial=0) #investment in player 1
     return return_amounts
Пример #27
0
def make_field_smoker_type(index):
    return models.IntegerField(
        label=Constants.smoker_type[index - 1],
        widget=widgets.RadioSelectHorizontal,
        choices=Constants.L5_CHOICES,
    )
Пример #28
0
class Player(BasePlayer):
    task = models.IntegerField(min=20, max=396)

    attempted_individual = models.IntegerField()
    correct_individual = models.IntegerField()
    attempted_cycles = models.IntegerField()
    correct_cycles = models.IntegerField()
    idle_time = models.IntegerField()

    def task1_before_next_page(self):
        self.participant.vars['stage2_attempted_individual'] += 1
        num1 = self.session.vars['numbers2'][0][self.round_number - 1]
        num2 = self.session.vars['numbers2'][1][self.round_number - 1]
        if self.task == num1 + num2:
            self.participant.vars['stage2_correct_individual'] += 1
            self.group.get_player_by_id(
                1).participant.vars['stage2_currentcyclecorrect?'] = True
        else:
            self.group.get_player_by_id(
                1).participant.vars['stage2_currentcyclecorrect?'] = False

    def task2_before_next_page(self):
        self.participant.vars['stage2_attempted_individual'] += 1
        if self.round_number in range(1, 31) or self.round_number in range(
                91, 121):
            num1 = self.group.get_player_by_id(1).task
        elif self.round_number in range(31, 61) or self.round_number in range(
                121, 151):
            num1 = self.group.get_player_by_id(2).task
        else:
            num1 = self.group.get_player_by_id(3).task
        num2 = self.session.vars['numbers2'][2][self.round_number - 1]
        if self.task == num1 + num2:
            self.participant.vars['stage2_correct_individual'] += 1
            if self.group.get_player_by_id(
                    1).participant.vars['stage2_currentcyclecorrect?'] is True:
                self.group.get_player_by_id(
                    1).participant.vars['stage2_currentcyclecorrect?'] = True
            else:
                self.group.get_player_by_id(
                    1).participant.vars['stage2_currentcyclecorrect?'] = False
        else:
            self.group.get_player_by_id(
                1).participant.vars['stage2_currentcyclecorrect?'] = False

    def task3_before_next_page(self):
        self.participant.vars['stage2_attempted_individual'] += 1
        self.group.get_player_by_id(
            1).participant.vars['stage2_attempted_cycles'] += 1
        if self.round_number in range(1, 31) or self.round_number in range(
                91, 121):
            num1 = self.group.get_player_by_id(2).task
        elif self.round_number in range(31, 61) or self.round_number in range(
                121, 151):
            num1 = self.group.get_player_by_id(3).task
        else:
            num1 = self.group.get_player_by_id(1).task
        num2 = self.session.vars['numbers2'][3][self.round_number - 1]
        if self.task == num1 + num2:
            self.participant.vars['stage2_correct_individual'] += 1
            if self.group.get_player_by_id(
                    1).participant.vars['stage2_currentcyclecorrect?'] is True:
                self.group.get_player_by_id(
                    1).participant.vars['stage2_currentcyclecorrect?'] = True
            else:
                self.group.get_player_by_id(
                    1).participant.vars['stage2_currentcyclecorrect?'] = False
        else:
            self.group.get_player_by_id(
                1).participant.vars['stage2_currentcyclecorrect?'] = False
        if self.group.get_player_by_id(
                1).participant.vars['stage2_currentcyclecorrect?'] is True:
            self.group.get_player_by_id(
                1).participant.vars['stage2_correct_cycles'] += 1

    def display(self, order):
        if self.group.get_player_by_id(
                1).participant.vars['expiry'] - time.time() > 3:
            if self.round_number in range(1, 31) or self.round_number in range(
                    91, 121):
                return self.id_in_group == order[0]
            elif self.round_number in range(
                    31, 61) or self.round_number in range(121, 151):
                return self.id_in_group == order[1]
            else:
                return self.id_in_group == order[2]
        else:
            return False

    def num1(self, order):
        if self.round_number in range(1, 31) or self.round_number in range(
                91, 121):
            return self.group.get_player_by_id(order[0]).task
        elif self.round_number in range(31, 61) or self.round_number in range(
                121, 151):
            return self.group.get_player_by_id(order[1]).task
        else:
            return self.group.get_player_by_id(order[2]).task

    def save_and_reset_vars(self):
        # Add to payoffs
        self.payoff = c(30) * (self.group.get_player_by_id(
            1).participant.vars['stage2_correct_cycles'] // 2)
        # Save vars
        self.attempted_individual = self.participant.vars[
            'stage2_attempted_individual']
        self.correct_individual = self.participant.vars[
            'stage2_correct_individual']
        self.attempted_cycles = self.group.get_player_by_id(
            1).participant.vars['stage2_attempted_cycles']
        self.correct_cycles = self.group.get_player_by_id(
            1).participant.vars['stage2_correct_cycles']
        # Overall participant var
        self.participant.vars['stage2_total_mistakes_individual'] += \
            self.participant.vars['stage2_attempted_individual'] - self.participant.vars['stage2_correct_individual']

    def calculate_idle_time(self):
        waiting_pages = [
            'WaitForTask1',
            'WaitForTask2',
            'WaitForTask3',
        ]
        wp_sec = sum(
            PageCompletion.objects.filter(
                participant=self.participant,
                page_name__in=waiting_pages).values_list('seconds_on_page',
                                                         flat=True))
        self.idle_time = wp_sec
        self.participant.vars['stage2_idletime'] = wp_sec
Пример #29
0
def make_field_smoking_cessation_adverse(index):
    return models.IntegerField(
        label=Constants.smoking_cessation_adverse_effect[index - 1],
        widget=widgets.RadioSelectHorizontal,
        choices=Constants.L54_CHOICES,
    )
Пример #30
0
class Group(BaseGroup):
    pot1 = models.IntegerField(initial=0)
    pot2 = models.IntegerField(initial=0)
    pot3 = models.IntegerField(initial=0)
    pot4 = models.IntegerField(initial=0)
    pot5 = models.IntegerField(initial=0)
    pot6 = models.IntegerField(initial=0)
    pot7 = models.IntegerField(initial=0)
    pot8 = models.IntegerField(initial=0)
    pot9 = models.IntegerField(initial=0)
    pot10 = models.IntegerField(initial=0)

    contribution_round = models.IntegerField(initial=0)
    total_contribution = models.IntegerField(initial=0)
    lost = models.BooleanField(initial=False)