예제 #1
0
파일: models.py 프로젝트: janvavra/wuotree
class Group(BaseGroup):

    page_num = models.PositiveIntegerField(initial=0)
    cont = models.StringField(choices=Constants.dir_choices, initial='Right', widget=widgets.RadioSelect(),
                            doc = "Direction Choice")
    def count_pages(self):
        self.page_num += 1

    def set_payoff(self):
        for p in self.get_players():
            p.payoff=c(Constants.payoff_choices[self.page_num][(p.id_in_group-1)])

    def set_rand_payoff(self):
        for player in self.get_players():
            player.rand_payoff = c(random.choice([p.payoff for p in player.in_all_rounds()]))
    pass
예제 #2
0
class Player(BasePlayer):
    PartnerAgreement = models.StringField(
        choices=[['Strongly disagree', 'Strongly disagree'],
                 ['Somewhat disagree ', 'Somewhat disagree '],
                 ['Disagree ', 'Disagree '],
                 ['Neither agree nor disagree', 'Neither agree nor disagree'],
                 ['Somewhat agree', 'Somewhat agree'], ['Agree', 'Agree']],
        label=
        'I think that my partner and I are on the same wavelength with regard to our judgments of the video',
        widget=widgets.RadioSelectHorizontal)
    judgement1 = models.FloatField()
    certainty1 = models.FloatField()
    judgement2 = models.FloatField()
    certainty2 = models.FloatField()
    judgement3 = models.FloatField()
    certainty3 = models.FloatField()
예제 #3
0
class Player(BasePlayer):
    decision = models.StringField(
        choices=['Football', 'Opera'],
        doc="""Either football or the opera""",
        widget=widgets.RadioSelect()
    )

    def other_player(self):
        """Returns other player in group"""
        return self.get_others_in_group()[0]

    def role(self):
        if self.id_in_group == 1:
            return 'husband'
        if self.id_in_group == 2:
            return 'wife'
예제 #4
0
class Player(BasePlayer):
    treat = models.IntegerField()  # Treatments from 1 to 3
    given_type = models.IntegerField()  # combination of symbol and preference
    chosen_type = models.IntegerField()  # combination of symbol and preference
    was_circle = models.IntegerField()
    is_circle = models.IntegerField()
    action = models.IntegerField()  # Reported belief on P3's verification
    old_action = models.IntegerField()  # Reported belief on P3's verification
    liked_action = models.IntegerField()
    out_degree = models.IntegerField()
    degree = models.IntegerField()
    coordination_score = models.IntegerField()
    coordination_gains = models.IntegerField()
    linking_costs = models.IntegerField()
    round_gains = models.IntegerField()
    points_fluid = models.IntegerField()
    switch = models.IntegerField()

    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)
        }

    def var_between_apps(self):
        self.participant.vars['part_fluid_round'] = self.session.vars[
            'paying_round_2']
        self.participant.vars['part_fluid_payoff'] = self.points_fluid

    name = models.StringField()
    friends = models.LongStringField()
    position = models.IntegerField()

    for i in Constants.names:
        locals()[i] = models.BooleanField(widget=widgets.CheckboxInput,
                                          blank=True)
        # Añado a Player las variables de propuestas con friendly names que luego rellenaremos
        locals()['prop_to_' + i] = models.BooleanField(initial=0)
        locals()['prop_from_' + i] = models.BooleanField(initial=0)
        locals()['link_with_' + i] = models.IntegerField(initial=0)
        locals()['action_' + i] = models.IntegerField(initial=0)
        locals()['coordinate_' + i] = models.IntegerField(initial=0)

    del locals()['i']
예제 #5
0
class Player(BasePlayer):

    page_sequence = models.StringField()

    # Demographics
    Gender = models.IntegerField(label="Bitte geben Sie Ihr Geschlecht an:",
                                 choices=[
                                     [0, 'männlich'],
                                     [1, 'weiblich'],
                                     [2, 'divers']
                                 ],
                                 blank=False,
                                 widget=widgets.RadioSelect
                                 )

    Age = models.IntegerField(label="Bitte geben Sie Ihr Alter an:", blank=False)

    Qualification = models.IntegerField(label="Welches ist Ihr höchster Bildungsabschluss?",
                                        choices=[
                                            [0, 'noch Schüler/Schülerin'],
                                            [1, 'kein Bildungsgrad'],
                                            [2, 'Hauptschulabschluss'],
                                            [3, 'Realschulabschluss/mittlere Reife'],
                                            [4, 'abgeschlossene Berufsausbildung'],
                                            [5, 'Fachabitur/Fachhochschulreife'],
                                            [6, 'Abitur/Hochschulreife'],
                                            [7, 'Hochschulabschluss: Bachelor'],
                                            [8, 'Hochschulabschluss: Master'],
                                            [9, 'Promotion'],
                                            [10, 'sonstiger Abschluss']
                                        ],
                                        blank=False,
                                        widget=widgets.RadioSelect
                                        )

    # State items
    INT1 = make_field_7point('Ich würde das Apartment sehr wahrscheinlich buchen.')
    INT2 = make_field_7point('Ich würde in dem Apartment übernachten.')
    INT3 = make_field_7point('Ich würde nicht zögern, eine Buchungsanfrage für das Apartment zu senden.')

    # Mediennutzung
    MED1 = make_field_7point_plus_1('sogenannten Boulevardzeitungen oder deren Internet-Angeboten (z.B. Bild-Zeitung/bild.de,…)')
    MED2 = make_field_7point_plus_1('Privaten Radiosendern oder deren Internet-Angeboten (z.B. Energy/energy.de,…)')
    MED3 = make_field_7point_plus_1('Öffentlich-rechtlichen Radiosendern oder deren Internet-Angeboten (z.B. Deutschlandfunk/deutschlandfunk.de,…)')

    # Politik Verordnung
    POL1 = make_field_11point('Politischer Standpunkt')
예제 #6
0
class Player(BasePlayer):
    feedback = models.StringField(blank=True)
    tweet = models.StringField()
    choice1 = models.StringField()
    choice2 = models.StringField()
    choice3 = models.StringField()
    choice4 = models.StringField()
    pos_rating = make_field(Constants.positive)
    opt_rating = make_field(Constants.optimistic)
    hap_rating = make_field(Constants.happiness)
    emo_rating = make_field(Constants.emotional)
예제 #7
0
class Player(BasePlayer):
    choice1 = models.StringField(choices=['A', 'B',], widget=widgets.RadioSelectHorizontal,)
    choice2 = models.StringField(choices=['A', 'B',], widget=widgets.RadioSelectHorizontal,)
    choice3 = models.StringField(choices=['A', 'B',], widget=widgets.RadioSelectHorizontal,)
    choice4 = models.StringField(choices=['A', 'B',], widget=widgets.RadioSelectHorizontal,)
    choice5 = models.StringField(choices=['A', 'B',], widget=widgets.RadioSelectHorizontal,)
    choice6 = models.StringField(choices=['A', 'B',], widget=widgets.RadioSelectHorizontal,)
    choice7 = models.StringField(choices=['A', 'B',], widget=widgets.RadioSelectHorizontal,)
    choice8 = models.StringField(choices=['A', 'B',], widget=widgets.RadioSelectHorizontal,)


    # # # I made following fields just for testing purpose, remember to get it back before the real sessions
    # choice1 = models.StringField(choices=['A', 'B',], widget=widgets.RadioSelectHorizontal, blank=True)
    # choice2 = models.StringField(choices=['A', 'B',], widget=widgets.RadioSelectHorizontal, blank=True)
    # choice3 = models.StringField(choices=['A', 'B',], widget=widgets.RadioSelectHorizontal, blank=True)
    # choice4 = models.StringField(choices=['A', 'B',], widget=widgets.RadioSelectHorizontal, blank=True)
    # choice5 = models.StringField(choices=['A', 'B',], widget=widgets.RadioSelectHorizontal, blank=True)
    # choice6 = models.StringField(choices=['A', 'B',], widget=widgets.RadioSelectHorizontal, blank=True)
    # choice7 = models.StringField(choices=['A', 'B',], widget=widgets.RadioSelectHorizontal, blank=True)
    # choice8 = models.StringField(choices=['A', 'B',], widget=widgets.RadioSelectHorizontal, blank=True)

    x1 = models.FloatField()
    x2 = models.FloatField()
    p1 = models.FloatField()
    p2 = models.FloatField()
    s1 = models.FloatField()
    s2 = models.FloatField()
    s3 = models.FloatField()
    s4 = models.FloatField()
    s5 = models.FloatField()
    s6 = models.FloatField()
    s7 = models.FloatField()
    s8 = models.FloatField()
    
    
    # # # I tried to shuffle the lst in the player class, however, seems not work
    # shuffled_all_list = [([20, 0, 19.5, 17.0, 14.0, 11.5, 8.5, 6.0, 3.0, 0.5], 0.9), ([20, 10, 19.5, 18.0, 17.0, 15.5, 14.5, 13.0, 12.0, 10.5], 0.05), ([15, 5, 14.5, 13.0, 12.0, 10.5, 9.5, 8.0, 7.0, 5.5], 0.9), ([20, 0, 19.5, 17.0, 14.0, 11.5, 8.5, 6.0, 3.0, 0.5], 0.99), ([50, 0, 49.5, 42.5, 35.5, 28.5, 21.5, 14.5, 7.5, 0.5], 0.1), ([20, 10, 19.5, 18.0, 17.0, 15.5, 14.5, 13.0, 12.0, 10.5], 0.75), ([20, 10, 19.5, 18.0, 17.0, 15.5, 14.5, 13.0, 12.0, 10.5], 0.01), ([15, 5, 14.5, 13.0, 12.0, 10.5, 9.5, 8.0, 7.0, 5.5], 0.25), ([15, 5, 14.5, 13.0, 12.0, 10.5, 9.5, 8.0, 7.0, 5.5], 0.05), ([20, 0, 19.5, 17.0, 14.0, 11.5, 8.5, 6.0, 3.0, 0.5], 0.1), ([15, 5, 14.5, 13.0, 12.0, 10.5, 9.5, 8.0, 7.0, 5.5], 0.5), ([15, 5, 14.5, 13.0, 12.0, 10.5, 9.5, 8.0, 7.0, 5.5], 0.1), ([15, 5, 14.5, 13.0, 12.0, 10.5, 9.5, 8.0, 7.0, 5.5], 0.75), ([50, 0, 49.5, 42.5, 35.5, 28.5, 21.5, 14.5, 7.5, 0.5], 0.25), ([15, 5, 14.5, 13.0, 12.0, 10.5, 9.5, 8.0, 7.0, 5.5], 0.95), ([50, 0, 49.5, 42.5, 35.5, 28.5, 21.5, 14.5, 7.5, 0.5], 0.05), ([20, 10, 19.5, 18.0, 17.0, 15.5, 14.5, 13.0, 12.0, 10.5], 0.95), ([50, 0, 49.5, 42.5, 35.5, 28.5, 21.5, 14.5, 7.5, 0.5], 0.01), ([20, 10, 19.5, 18.0, 17.0, 15.5, 14.5, 13.0, 12.0, 10.5], 0.99), ([50, 0, 49.5, 42.5, 35.5, 28.5, 21.5, 14.5, 7.5, 0.5], 0.75), ([50, 0, 49.5, 42.5, 35.5, 28.5, 21.5, 14.5, 7.5, 0.5], 0.5), ([15, 5, 14.5, 13.0, 12.0, 10.5, 9.5, 8.0, 7.0, 5.5], 0.01), ([20, 10, 19.5, 18.0, 17.0, 15.5, 14.5, 13.0, 12.0, 10.5], 0.9), ([20, 0, 19.5, 17.0, 14.0, 11.5, 8.5, 6.0, 3.0, 0.5], 0.05), ([20, 0, 19.5, 17.0, 14.0, 11.5, 8.5, 6.0, 3.0, 0.5], 0.75), ([20, 0, 19.5, 17.0, 14.0, 11.5, 8.5, 6.0, 3.0, 0.5], 0.01), ([50, 0, 49.5, 42.5, 35.5, 28.5, 21.5, 14.5, 7.5, 0.5], 0.9), ([20, 10, 19.5, 18.0, 17.0, 15.5, 14.5, 13.0, 12.0, 10.5], 0.25), ([15, 5, 14.5, 13.0, 12.0, 10.5, 9.5, 8.0, 7.0, 5.5], 0.99), ([20, 0, 19.5, 17.0, 14.0, 11.5, 8.5, 6.0, 3.0, 0.5], 0.95), ([20, 10, 19.5, 18.0, 17.0, 15.5, 14.5, 13.0, 12.0, 10.5], 0.5), ([20, 0, 19.5, 17.0, 14.0, 11.5, 8.5, 6.0, 3.0, 0.5], 0.5), ([50, 0, 49.5, 42.5, 35.5, 28.5, 21.5, 14.5, 7.5, 0.5], 0.95), ([20, 0, 19.5, 17.0, 14.0, 11.5, 8.5, 6.0, 3.0, 0.5], 0.25), ([20, 10, 19.5, 18.0, 17.0, 15.5, 14.5, 13.0, 12.0, 10.5], 0.1), ([50, 0, 49.5, 42.5, 35.5, 28.5, 21.5, 14.5, 7.5, 0.5], 0.99)]
    #
    # random.shuffle(shuffled_all_list)

    # question_id = models.StringField() # set a field here, i think this should be the solution, since different player have different questhin order
                                         # another stupid way is to create 16 different list.
                                         # this seems very complicated, I need to get a long string and transfer it back to lst, and shuffle
    pass
예제 #8
0
class Player(BasePlayer):
    def before_next_page(self):
        self.fake_svo_angle = self.participant.vars['fangle'][0]
        self.fake_svo_classification = slider.svo_classification(self.fake_svo_angle)
        self.individual_share_a = self.participant.vars['fshare']
        self.shared_point = Constants.endowment - self.participant.vars['fshare']

    def set_payoff(self):
        """Calculate payoff, to be implemented later """
        self.payoff = 0

    slider1 = models.FloatField()
    slider2 = models.FloatField()
    slider3 = models.FloatField()
    slider4 = models.FloatField()
    slider5 = models.FloatField()
    slider6 = models.FloatField()
    offer_accept = models.BooleanField(choices=[[True, u'接受'], [False, u'不接受']],
                                       widget=widgets.RadioSelectHorizontal, label=u'你是否接受这个方案?')
    slider_angle = models.DecimalField(decimal_places=2, max_digits=5)
    slider_classification = models.CharField()
    fake_svo_angle = models.DecimalField(decimal_places=2, max_digits=5)
    fake_svo_classification = models.CharField()
    individual_share_a = models.IntegerField()
    shared_point = models.IntegerField()
    feeling_rating = models.IntegerField()
    name = models.StringField(label = u'请输入您的姓名')
    age = models.IntegerField(label=u'请输入您的年龄')
    gender = models.IntegerField(label=u'请输入您的性别',choices=[[1,u'男'],[2,u'女']])
    education = models.StringField(label=u'请输入您的受教育程度',blank=True,choices=[u'小学',u'中学',u'高中',u'大学',]
                                   + [u'大学后进阶教育 %d 年' %y for y in range(1,10)] +[u'持续进阶教育达到 10年及以上',])
    career = models.StringField(label = u'请输入您的职业')
    contact = models.StringField(label = u'请输入您的联系方式(支付宝绑定的手机号)')
    subjectid = models.StringField(label=u'请输入您的身份证号(用于报销凭证)')
    otherinfo = models.StringField(label = u'如有被试费用相关信息请在此处,请在此处说明')
    def vars_for_template(self):
        if self.round_number ==1:
            print (self.participant.vars['fangle'][0], self.participant.vars['fshare'])
            return {'svo_slider_angle': self.slider_angle,
                    'slider_classification': slider.svo_classification(self.slider_angle),
                    'fake_svo_angle': self.participant.vars['fangle'][0],
                    'fake_svo_classification': slider.svo_classification(self.fake_svo_angle),
                    'individual_share_a':self.participant.vars['fshare'],
                    'shared_point': Constants.endowment - self.participant.vars['fshare'],
                    }
        else:
            round_1_player = self.in_round(1)
            return {'svo_slider_angle': round_1_player.slider_angle,
                    'slider_classification': round_1_player.slider_classification,
                    'fake_svo_angle': self.participant.vars['fangle'][0],
                    'fake_svo_classification': slider.svo_classification(self.fake_svo_angle),
                    'individual_share_a':self.participant.vars['fshare'],
                    'shared_point': Constants.endowment - self.participant.vars['fshare']
                    }
예제 #9
0
class Task2(djmodels.Model):
    class Meta:
        """We also do not crucially need this but it is convenient to pick just the most recent unanswered task.
        Ideally there should be just one, but just in case it is better to be safe."""
        get_latest_by = 'created_at'

    player = djmodels.ForeignKey(to=Player, related_name='tasks2')
    question = djmodels.ForeignKey(to=Q2, related_name='answers')
    answer = models.StringField()
    created_at = models.DateTimeField(auto_now_add=True)  # this and the following field is to track time
    updated_at = models.DateTimeField(auto_now=True)
    test = models.BooleanField()

    def get_answer_time(self):
        """We need this to show the question durations for the user in a nice mode."""
        sec = (self.updated_at - self.created_at).total_seconds()
        return f'{int((sec / 60) % 60):02d}:{int(sec):02d}'
class Player(BasePlayer):
    dice = models.IntegerField(min=1, max=6,
                               verbose_name='Por favor informe el número del dado')
    report = models.StringField(verbose_name='Informe el dado del sistema', blank=True)

    def set_payoff(self):
        self.payoff = Constants.report_coef * self.dice
        self.participant.vars[self.session_id]['part3_payoff'] = self.payoff / 1.0

# For Questionnaire

    age = models.IntegerField(
        verbose_name='Edad',
        min=18, max=125)

    gender = models.IntegerField(
        choices=[[1, 'Hombre'], [2, 'Mujer'],[9, 'Otro']],
        verbose_name='Sexo',
        widget=widgets.RadioSelect)

    ideology = models.IntegerField(
        choices=[[0, '0'], [1, '1'], [2, '2 '], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7'], [8, '8 '], [9, '9'], [ 10, '10. Derecha ']],
        verbose_name='En política se habla normalmente de "izquierda" y "derecha". En una escala donde "0" es la "izquierda" y 10 la "derecha", ¿dónde se ubicaría?',
        widget=widgets.RadioSelectHorizontal)

    trust = models.IntegerField(
        choices=[[1,'Se puede confiar en la mayoría de las personas'], [2, 'Uno nunca es lo suficientemente cuidadoso en el trato con los demás']],
        verbose_name=' En general, ¿diría que se puede confiar en la mayoría de las personas o que uno nunca es lo suficientemente cuidadoso en el trato con los demás?',
        widget=widgets.RadioSelect)

    occupation = models.IntegerField(
        choices=[[1,'Estudiante'], [2, 'Trabajador(a)'], [9, 'Otro']],
        verbose_name='¿Cuál es su ocupación principal?',
        widget=widgets.RadioSelect)

    scholarship = models.IntegerField(
        choices=[[1,'Sí'], [2, 'No'], [9, 'No aplica']],
        verbose_name='Si es estudiante universitario, por favor indique si es beneficiario/a de alguna beca',
        widget=widgets.RadioSelect)

    type_scholarship = models.IntegerField(
        choices=[[1,'Por méritos académicos'], [2, 'Por razones económicas'], [9, 'No aplica']],
        verbose_name='Si es beneficiaria/o, por favor indique la razón por la cual ha obtenido la beca que le cubra la mayor parte de sus gastos universitarios.',
        widget=widgets.RadioSelect)

    payoff2 = models.IntegerField()
예제 #11
0
class Player(BasePlayer):
    # the player's total payoff in all rounds
    payoff = models.CurrencyField(initial=0)

    # the amount that is offered for each player in every round
    amount_offered = models.CurrencyField(initial=0)

    total_amount_offered = models.CurrencyField(initial=0)

    # the total number of points the proposer and the divider had to divide between themselves.
    # usually, current_endowment = round_number * endowment
    current_endowment = models.CurrencyField(initial=0)

    # the message displayed to the player in 'complex' mode
    message = models.StringField(initial='')

    # indicates if the offer was accepted or not
    offer_accepted = models.BooleanField()

    # indicates if the 'complex' mode is on or not
    complex_mode = models.BooleanField(initial=False)

    def set_payoff(self):
        if self.offer_accepted:
            if self.round_number > 1:
                self.payoff = self.amount_offered + self.in_round(
                    self.round_number - 1).payoff
            else:
                self.payoff = self.amount_offered
        else:  # offer rejected
            if self.round_number > 1:
                self.payoff = Constants.payoff_if_rejected + self.in_round(
                    self.round_number - 1).payoff
            else:
                self.payoff = Constants.payoff_if_rejected

    def set_total_amount_offered(self):
        if self.round_number > 1:
            self.total_amount_offered = self.amount_offered + self.in_round(
                self.round_number - 1).total_amount_offered
        else:
            self.total_amount_offered = self.amount_offered

    def set_message(self):
        if self.complex_mode:
            self.message = random.choice(Constants.messages)
예제 #12
0
파일: models.py 프로젝트: fightbnu/Papers
class Player(BasePlayer):
    offerAcceptedA = models.BooleanField(blank=True)
    offerAcceptedB = models.BooleanField(blank=True)
    sentAccountA = models.IntegerField()    #
    sentAccountB = models.IntegerField()    #
    roundWinner = models.StringField()      #
    playerAGive = models.IntegerField() # A给
    playerBGive = models.IntegerField() # B给
    playerAGain = models.IntegerField() # A收
    playerBGain = models.IntegerField() # B收
    selfGain = models.IntegerField()    # 裁判收
    All_A = models.IntegerField()   #A总
    All_B = models.IntegerField()   #B总

    pass
# function:定义玩家属性;
# function: 定义sentAcountA,B:为什么在subsession里边定义
예제 #13
0
class Player(BasePlayer):
    #genero de los participante
    genero = models.StringField(choices=['Masculino', 'Femenino'],
                                doc="""Esto es el género del jugador""",
                                widget=widgets.RadioSelect)

    #edad del participante
    edad = models.IntegerField(min=18)

    #unidades que produce el jugador
    unidades = models.IntegerField(
        min=0,
        max=Constants.max_units_per_player,
        doc="""Cantidad de unidades a producir del jugador""")

    def other_player(self):
        return self.get_others_in_group()[0]
예제 #14
0
class Player(BasePlayer):
    ## needs to change server and qualificaiton types before the experiment
    workerid = models.StringField()
    consent = models.BooleanField()
    independent = models.BooleanField()

    def workerid_error_message(self, value):
        print('value is', value, self.session.config['access_key_id'])
        if not self.session.config['debug']:
            access_key_id = self.session.config['access_key_id']
            secret_access_key = self.session.config['secret_access_key']
            print('access_key_id', access_key_id,
                  environ.get('AWS_ACCESS_KEY_ID'))
            print('secret_access_key', secret_access_key,
                  environ.get('AWS_SECRET_ACCESS_KEY'))
            if self.session.config['sandbox']:  # sandbox
                Qid = self.session.config['Qid_sandbox']
                mturk = boto3.client(
                    service_name='mturk',
                    aws_access_key_id=access_key_id,
                    aws_secret_access_key=secret_access_key,
                    region_name='us-east-1',
                    endpoint_url=
                    "https://mturk-requester-sandbox.us-east-1.amazonaws.com",
                )
            else:  # live production
                Qid = self.session.config['Qid']
                mturk = boto3.client(
                    service_name='mturk',
                    aws_access_key_id=access_key_id,
                    aws_secret_access_key=secret_access_key,
                    region_name='us-east-1',
                )
            try:
                mturk.associate_qualification_with_worker(
                    QualificationTypeId=Qid,
                    WorkerId=value,
                    IntegerValue=0,
                    SendNotification=False)
            except Exception as e:
                print(
                    e,
                    value,
                    Qid,
                )
                return 'Please input a valid Worker ID.'
예제 #15
0
class Player(BasePlayer):
    type = models.IntegerField()
    status = models.IntegerField()
    status_name = models.StringField()
    partner_id = models.IntegerField()
    partner_type = models.IntegerField()
    signal = models.IntegerField()
    choice = models.IntegerField(choices=[
        [1, 'Yes'],
        [0, 'No'],
    ],
                                 widget=widgets.RadioSelectHorizontal,
                                 blank=True)
    partner_choice = models.IntegerField()
    match = models.IntegerField()
    late = models.IntegerField()
    points = models.IntegerField()
예제 #16
0
class Player(BasePlayer):
    risk_preference = models.IntegerField()
    fail_counter_heads = models.IntegerField()
    fail_counter_tails = models.IntegerField()

    time_preference_1 = models.StringField()
    time_preference_2 = models.StringField()
    time_preference_3 = models.StringField()
    time_preference_4 = models.StringField()
    time_preference_5 = models.StringField()
    time_preference_6 = models.StringField()
    fail_counter_tp = models.IntegerField()
예제 #17
0
class Group(BaseGroup):

    alias_assignment = models.StringField
    alias_string = models.StringField
    Red_price = models.FloatField(initial=0.5)
    Green_price = models.FloatField(initial=0.5)

    Michael_index = models.IntegerField(choices=[1, 2, 3])
    Dwight_index = models.IntegerField(choices=[1, 2, 3])
    Jim_index = models.IntegerField(choices=[1, 2, 3])
    role_by_order = models.StringField()

    # New groups keep getting created even when new subsessions are not. dafuq
    def __init__(self, *args, **kwargs):
        BaseGroup.__init__(self, *args, **kwargs)
        np.random.seed(self.id_in_subsession)
        self.alias_assignment = np.random.permutation(Constants.characters)
        self.alias_string = ', '.join(self.alias_assignment)
예제 #18
0
class Player(BasePlayer):
    decision = models.StringField(choices=['Cooperate', 'Defect'],
                                  doc="""This player's decision""",
                                  widget=widgets.RadioSelect)

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

    def set_payoff(self):

        payoff_matrix = dict(Cooperate=dict(
            Cooperate=Constants.both_cooperate_payoff,
            Defect=Constants.betrayed_payoff),
                             Defect=dict(Cooperate=Constants.betray_payoff,
                                         Defect=Constants.both_defect_payoff))

        self.payoff = payoff_matrix[self.decision][
            self.other_player().decision]
예제 #19
0
class Player(BasePlayer):

    age = models.IntegerField(label='What is your age?', min=13, max=125)

    gender = models.StringField(choices=['Male', 'Female', 'Other'],
                                label='What is your gender?',
                                widget=widgets.RadioSelect)

    education = models.StringField(
        choices=[
            'No schooling', 'Primary School', 'Middle School', 'High School',
            'Some College', 'Trade/Technical/Vocational Training',
            'Associate Degree', 'Bachelor\'s Degree', 'Master\'s Degree',
            'Doctorate'
        ],
        label='What is your highest level of education attained?',
        widget=widgets.RadioSelect)

    language = models.StringField(label='What is your native language?',
                                  widget=widgets.TextInput)

    country = models.StringField(label='In which country were you born?',
                                 widget=widgets.TextInput)

    intent = models.StringField(
        choices=[
            'Selfish', 'Generous', 'Hostile', 'Cooperative', 'Rational',
            'Irrational'
        ],
        label=
        'What do you think the intent of the other player was in their decisions?',
        widget=widgets.RadioSelect)

    identity = models.StringField(
        choices=['Yes', 'No', 'Maybe'],
        label=
        'If you knew the identity of the other player, would you have made a different decision?',
        widget=widgets.RadioSelect)

    risk = models.StringField(
        choices=[
            '0 risk averse', '1', '2', '3', '4', '5', '6', '7', '8', '9',
            '10 fully prepared to take risks'
        ],
        label=
        'How do you rate yourself personally? In general, are you someone who is ready to take risks or do you try to avoid risks? \n Please provide your answers using the scale provided again. 0 means “Not prepared to take risks at all”. 10 means “Prepared to take risks”. You can use the in-between ratings to tailor your response.',
        widget=widgets.RadioSelect)
예제 #20
0
class Player(BasePlayer):
    real_die_value = models.IntegerField()  # virtual dice value report
    modelPred = models.IntegerField(choices=[(1, 'Top Third'),
                                             (2, 'Middle Third'),
                                             (3, 'Bottom Thrid')],
                                    widget=widgets.RadioSelect)
    roundPred = models.IntegerField(choices=[1, 2, 3],
                                    widget=widgets.RadioSelect)
    chosen_round = models.IntegerField()
    roundPred_correct = models.BooleanField()
    modelPred_correct = models.BooleanField()
    matched_payoff = models.IntegerField()
    matched_level = models.StringField()

    dice_value = models.IntegerField(min=1, max=6)

    def roll_die(self):
        self.real_die_value = random.randint(1, 6)
예제 #21
0
class FruitOffer(Model):
    """
    Custom data model derived from Django's generic `Model` class. This class defines an offer of fruit with three
    properties:
    - amount of available fruit
    - selling price per item
    - kind of fruit

    Additionally, a reference to the seller is stored via a `ForeignKey` to `Player`.
    """

    KINDS = (
        ('Apple', 'Apple'),
        ('Orange', 'Orange'),
        ('Banana', 'Banana'),
    )
    PURCHASE_PRICES = {
        'Apple': c(0.20),
        'Orange': c(0.30),
        'Banana': c(0.50),
    }

    amount = models.IntegerField(label='Amount', min=0, initial=0)           # number of fruits available
    price = models.CurrencyField(label='Price per fruit', min=0, initial=0)
    kind = models.StringField(choices=KINDS)
    # easy to add more attributes per fruit, e.g.:
    #is_organic = models.BooleanField()   # if True: organic fruit, else conventional

    seller = ForeignKey(Player)    # creates many-to-one relation -> this fruit is sold by a certain player, a player
                                   # can sell many fruits

    class CustomModelConf:
        """
        Configuration for otreeutils admin extensions.
        This class and its attributes must be existent in order to include this model in the data viewer / data export.
        """
        data_view = {
            'exclude_fields': ['seller_id'],
            'link_with': 'seller'
        }
        export_data = {
            'exclude_fields': ['seller_id'],
            'link_with': 'seller'
        }
예제 #22
0
class Player(BasePlayer):
    count = models.IntegerField(min=0, label='How many ones are in the table?')
    correct_counts = models.IntegerField(initial=0)
    counts_submitted = models.IntegerField(initial=0)
    pay_for_round = models.CurrencyField(initial=c(0))
    claimed_earnings = models.CurrencyField(
        label='My declared income for this round is',
        min=c(0)
    )
    tax_audit = models.BooleanField()
    tax_message = models.StringField()
    tax_on_claimed = models.CurrencyField(initial=c(0))
    post_tax_earnings = models.CurrencyField(initial=c(0))
    final_earnings = models.CurrencyField(initial=c(0))
    
    def check_answer(self):
        self.counts_submitted += 1
        if self.count == self.participant.vars['next_correct_answer']:
            self.correct_counts += 1
            self.pay_for_round += Constants.table_pay
    
    def update_iterator(self):
        self.participant.vars['i'] += 1
        if self.participant.vars['i'] >= Constants.max_tables_in_round:
            self.participant.vars['i'] = 0
    
    def handle_taxes(self):
        self.tax_audit = choice([True, False], p=[0.2, 0.80])
        self.tax_on_claimed = self.claimed_earnings*Constants.tax_rate
        self.post_tax_earnings = self.pay_for_round - self.tax_on_claimed
        if self.tax_audit:
            self.tax_message = 'You have been audited. '
            if self.claimed_earnings >= self.pay_for_round:
                self.tax_message = self.tax_message + 'However, you disclosed all of your earnings, so don\'t face any penalties.'
                self.final_earnings = self.post_tax_earnings
            else:
                not_claimed = self.pay_for_round - self.claimed_earnings
                extra_tax = not_claimed*2*Constants.tax_rate
                self.tax_message = self.tax_message + f'You did not disclose {not_claimed} ECU of your earnings. You are fined a {extra_tax} ECU penalty.'
                self.final_earnings = self.post_tax_earnings - extra_tax
        else:
            self.tax_message = 'You have not been audited this round.'
            self.final_earnings = self.post_tax_earnings
        self.participant.vars['payoff'] += self.final_earnings
예제 #23
0
class Player(BasePlayer):

    id_position = models.IntegerField()
    poll = models.StringField(
        choices=['K', 'J', 'Prefer not to participate in the Poll'],
        widget=widgets.RadioSelect,
    )
    vote = models.StringField(
        choices=['K', 'J', 'Abstain'],
        widget=widgets.RadioSelect,
    )

    company_each_player = models.StringField(
    )  # for instance, player 1 is selected by company A B C, player 2 is selected by company A D....

    belief_k = models.IntegerField(
        validators=[MaxValueValidator(100),
                    MinValueValidator(0)])

    belief_j = models.IntegerField(
        validators=[MaxValueValidator(100),
                    MinValueValidator(0)])

    # Survey
    gender = models.StringField(
        blank=True,
        choices=['M', 'F', 'Other', 'Prefer not to answer'],
        widget=widgets.RadioSelect)
    nationality = models.StringField(blank=True)
    major = models.StringField(blank=True)
    income = models.StringField(blank=True,
                                choices=[
                                    'Less than £40,000', '£40,000-70,000',
                                    '£70,000 -£100,000', 'more than £100,000'
                                ],
                                widget=widgets.RadioSelect)

    # # # try to resolve the total payoff issue
    total_payoffs = models.FloatField(
    )  # note that it's a little bit different from the var in page.py

    # # # in the poll result page, random order of K, J display across subjects
    poll_display_order = models.IntegerField(
    )  # if this var = 0, K before J; if this var = 1, J before K.

    pass
예제 #24
0
파일: models.py 프로젝트: janvavra/wuotree
class Player(BasePlayer):
    number_of_bottles = models.PositiveIntegerField(
        min=0, max=Constants.max_bottles, doc="""Number of bottles""")

    role = models.StringField(doc="""Role: Producer 1 or Producer 2""")

    def get_role(self):
        if self.id_in_group == 1:
            self.participant.vars['role'] = 'Producer 1'
        elif self.id_in_group == 2:
            self.participant.vars['role'] = 'Producer 2'

    def retrieve_role(self):
        if self.participant.vars['role'] == 'Producer 1':
            self.role = 'Producer 1'
        if self.participant.vars['role'] == 'Producer 2':
            self.role = 'Producer 2'

    pass
예제 #25
0
class Task(djmodels.Model):
    player = djmodels.ForeignKey(to=Player, related_name='tasks')
    question = ListField()
    correct_answer = ListField()
    digits = ListField()
    letters = ListField()
    answer = models.StringField(null=True)
    # TODO: implement boolean
    is_correct = models.BooleanField()

    def get_body(self):
        return {
            'question': self.question,
            'digits': self.digits,
            'letters': self.letters,
        }

    def decoding_dict(self):
        keys = self.digits
        values = self.letters
        dictionary = dict(zip(keys, values))
        return dictionary

    def get_decoded(self, to_decode):
        decdict = self.decoding_dict()
        return [decdict[i] for i in to_decode]

    def as_dict(self):
        # TODO: clean the mess with the body
        return {'correct_answer': self.correct_answer, 'body': self.get_body()}

    @classmethod
    def post_create(cls, sender, instance, created, *args, **kwargs):
        if not created:
            return
        digs = list(string.digits)
        random.shuffle(digs)
        instance.digits = digs
        lts = random.sample(string.ascii_lowercase, k=Constants.num_letters)
        instance.letters = lts
        instance.question = random.choices(string.digits, k=Constants.task_len)
        instance.correct_answer = instance.get_decoded(instance.question)
        instance.save()
예제 #26
0
class Player(BasePlayer):
    decision = models.StringField(choices=[['Work alone', 'Work alone'],
                                           ['Cooperate', 'Cooperate'],
                                           ['Steal', 'Steal']],
                                  widget=widgets.RadioSelect)
    social_trust = models.IntegerField(
        choices=[[i, i] for i in range(11)],
        label=
        "How well do you trust the other members of your group to cooperate? (where 1 is not at all and 10 is totally)"
    )
    outcome = models.LongStringField()
    energy_level = models.CurrencyField()
    delta_energy_level = models.CurrencyField(initial=0)
    delta_energy_level_absolute = models.CurrencyField(initial=0)
    random_energy_cost = models.CurrencyField(initial=0)
    random_energy_cost_absolute = models.CurrencyField(initial=0)
    mock_payoff = models.CurrencyField()
    rounds_below_threshold = models.IntegerField()
    current_running = models.CurrencyField()
예제 #27
0
class Player(BasePlayer):
    age = models.IntegerField(min=18, max=99, label="What is your age?")
    gender = models.StringField(
        choices=['Male', 'Female', 'Other', 'I don\'t want to say it'],
        label='What is your gender?')
    math_grade = models.FloatField(blank=True,
                                   min=1,
                                   max=6,
                                   label='What was your last math grade?')
    falk_time = models.IntegerField(
        choices=list(range(11)),
        widget=widgets.RadioSelectHorizontal,
        label=
        "How willing are you to give up something that is beneficial for you today in order to benefit more from that in the future?"
    )

    # Additional field to check if the participant wants to revise the answer
    revise_question = models.BooleanField(
        label="Do you want to change your answers?")
예제 #28
0
파일: models.py 프로젝트: kutrifd/project
class Player(BasePlayer):
    dump_answer = models.StringField(
        doc='storing svo answers in a string for demo and export purposes')
    mean_ego = models.FloatField()
    mean_alter = models.FloatField()
    svo_angle = models.FloatField()
    svo_type = models.CharField()

    def dumping_answer(self):
        q = self.svo_set.all()
        return [i.to_dump() for i in q]

    def set_svo_angle(self):
        q = self.svo_set.all()
        tot_egos = [i.get_ego_value() for i in q]
        tot_alters = [i.get_alter_value() for i in q]
        self.mean_ego = sum(tot_egos) / len(tot_egos)
        self.mean_alter = sum(tot_alters) / len(tot_alters)
        mean_ego = self.mean_ego - 50
        mean_alter = self.mean_alter - 50
        svo_ratio = mean_alter / mean_ego
        angle_radians = math.atan(svo_ratio)
        self.svo_angle = math.degrees(angle_radians)
        return self.svo_angle

    def set_svo_type(self):
        assert isinstance(self.svo_angle,
                          float), 'Cannot define svo type without svo angle'
        angle = self.svo_angle
        if -70 < angle <= -12.04:
            st = 'Competitive'
        if -12.04 < angle <= 22.45:
            st = 'Individualistic'
        if 22.45 < angle <= 57.15:
            st = 'Prosocial'
        if 57.15 < angle <= 120:
            st = 'Altruist'
        assert st is not None, 'Cannot define the current svo type based on data.'
        self.svo_type = st
        return st

    def unanswered_svo_left(self):
        return self.svo_set.filter(answer__isnull=True).exists()
예제 #29
0
class Player(BasePlayer):

    # Required if the ORSEE ID is not passed via the
    # participant label.
    orsee_id = models.StringField(
        label="Bitte geben Sie Ihre Teilnehmer-ID ein:")

    def create_paymentURL(self):
        """

        Small helper function to create a payment URL.
        """
        expShortName = self.session.config['expShortName']
        expId = self.session.config['expId']
        pid = self.participant.label
        final_payoff = float(self.participant.payoff_plus_participation_fee())
        paymentURL = PayoutURLGenerator(expShortName, expId, pid,
                                        final_payoff).getPayoutURL()
        return paymentURL
예제 #30
0
class Player(BasePlayer):
    sender_allocation = models.CurrencyField(min=0, max=Constants.endowment)
    sender_expectation = models.IntegerField(min=0, max=900)

    def role(self):
        if self.id_in_group == 2:
            return 'distributor'
        if self.id_in_group == 3:
            return 'sender 1'
        if self.id_in_group == 4:
            return 'sender 2'
        if self.id_in_group == 1:
            return 'sender 3'

    survey1 = models.StringField(choices=['Male', 'Female', 'Non-Binary', 'I prefer not to say'],
                                 widget=widgets.RadioSelect)
    survey2 = models.LongStringField(blank=True)

    survey3 = models.LongStringField(blank=True)