Пример #1
0
class Player(otree.models.BasePlayer):

    # <built-in>
    group = models.ForeignKey(Group, null=True)
    subsession = models.ForeignKey(Subsession)
    # </built-in>

    contribution = models.PositiveIntegerField(
        default=None,
        doc="""The amount contributed by the player""",
        widget=widgets.TextInput())

    points = models.PositiveIntegerField(null=True)

    question = models.PositiveIntegerField(null=True,
                                           verbose_name='',
                                           widget=widgets.TextInput())
    feedbackq = models.CharField(
        null=True,
        verbose_name='How well do you think this sample game was implemented?',
        widget=widgets.RadioSelectHorizontal())

    def feedbackq_choices(self):
        return ['Very well', 'Well', 'OK', 'Badly', 'Very badly']

    def question_correct(self):
        return self.question == self.subsession.question_correct

    def contribution_error_message(self, value):
        if not 0 <= value <= self.subsession.endowment:
            return 'Your entry is invalid.'
Пример #2
0
class Player(BasePlayer):
    def score_round(self):
        # update player payoffs
        if (self.solution == self.user_total):
            self.is_correct = True
            self.payoff_score = 1
        else:
            self.is_correct = False
            self.payoff_score = c(0)

    task_timer = models.PositiveIntegerField(
        doc="""The length of the real effort task timer.""")

    int1 = models.PositiveIntegerField(doc="this round's first int")

    int2 = models.PositiveIntegerField(doc="this round's second int")

    solution = models.PositiveIntegerField(
        doc="this round's correct summation")

    user_total = models.PositiveIntegerField(
        min=1,
        max=9999,
        doc="user's summation",
        widget=widgets.TextInput(attrs={'autocomplete': 'off'}))

    is_correct = models.BooleanField(doc="did the user get the task correct?")

    payoff_score = models.FloatField(doc='''score in this task''')
Пример #3
0
class Player(BasePlayer):
    def score_round(self):
        # update player payoffs
        if self.solution == self.user_total:
            self.is_correct = True
            self.payoff_score = 1
        else:
            self.is_correct = False
            self.payoff_score = c(0)

    def set_task_score(self):
        op_scores = []
        for op in self.get_others_in_group():
            op_scores.append(int(op.participant.vars['task_2_score']))
        self.participant.vars['task_2_op_scores'] = op_scores

    task_timer = models.PositiveIntegerField(
        doc="""The length of the real effort task timer.""")

    solution = models.PositiveIntegerField(
        doc="this round's correct summation")

    user_total = models.PositiveIntegerField(
        min=1,
        max=9999,
        doc="user's summation",
        widget=widgets.TextInput(attrs={'autocomplete': 'off'}))

    is_correct = models.BooleanField(doc="did the user get the task correct?")

    payoff_score = models.FloatField(doc='''score in this task''')
Пример #4
0
class Player(BasePlayer):

    def score_round(self):
        # update player payoffs
        if (self.correct_text == self.user_text):
            self.is_correct = True
            self.payoff_score = 1
        else:
            self.is_correct = False
            self.payoff_score = 0


    task_timer = models.PositiveIntegerField(
        doc="""The length of the real effort task timer."""
    )

    correct_text = models.CharField(
        doc="user's transcribed text")

    user_text = models.CharField(
        doc="user's transcribed text",
        widget=widgets.TextInput(attrs={'autocomplete':'off'}))

    is_correct = models.BooleanField(
        doc="did the user get the task correct?")

    ret_final_score = models.IntegerField(
        doc="player's total score up to this round")

    payoff_score = models.FloatField(
            doc = '''score in this task'''
        )
Пример #5
0
class Player(BasePlayer):

    turk_id = models.CharField(
        verbose_name='Please enter your Mechanical Turk ID',
        widget=widgets.TextInput())

    clear = models.PositiveIntegerField(
        choices=[[1, 'Very clear'], [2, 'Somewhat clear'],
                 [3, 'Neither clear nor unclear'], [4, 'Somewhat unclear'],
                 [5, 'Very unclear']],
        verbose_name='How clear were the instructions to play the game?',
        widget=widgets.RadioSelectHorizontal())

    timing_instr = models.PositiveIntegerField(
        choices=[
            [1, 'Very long'],
            [2, 'Somewhat long'],
            [3, 'Just right'],
            [4, 'Somewhat short'],
            [5, 'Very short'],
        ],
        verbose_name=
        'How was the allocated timing to read the instructions? i.e. Did you have enough time to read the instructions before the page automatically forwards?',
        widget=widgets.RadioSelectHorizontal())

    timing_dec = models.PositiveIntegerField(
        choices=[[1, 'Very fast'], [2, 'Somewhat fast'], [3, 'Just right'],
                 [4, 'Somewhat slow'], [5, 'Very slow']],
        verbose_name=
        'How was the allocated timing for the decision making page? (The page each round that asks for your decision) i.e. Did you have enough time to make an informed decision before the page automatically forwards?',
        widget=widgets.RadioSelectHorizontal())

    timing_res = models.PositiveIntegerField(
        choices=[[1, 'Very fast'], [2, 'Somewhat fast'], [3, 'Just right'],
                 [4, 'Somewhat slow'], [5, 'Very slow']],
        verbose_name=
        'How was the allocated timing for the page displaying the results of the game? (The page that shows the outcome for each round) i.e. Did you have enough time to read the results of each round before the page automatically forwards?',
        widget=widgets.RadioSelectHorizontal())

    diff = models.PositiveIntegerField(
        choices=[[1, 'Very easy'], [2, 'Somewhat easy'],
                 [3, 'Neither easy nor difficult'], [4, 'Somewhat difficult'],
                 [5, 'Very difficult']],
        verbose_name='How easy was it to understand the goal of the game?',
        widget=widgets.RadioSelectHorizontal())

    comment = models.CharField(
        verbose_name='Please write any comments or suggestions about the game',
        widget=widgets.Textarea())

    def role(self):
        if self.id_in_group == 1:
            return 'attacker'
        if self.id_in_group == 2:
            return 'defender'
        if self.id_in_group == 3:
            return 'user'
Пример #6
0
class Player(otree.models.BasePlayer):

    # <built-in>
    group = models.ForeignKey(Group, null=True)
    subsession = models.ForeignKey(Subsession)
    # </built-in>

    demo_field1 = models.CharField(
        default=None,
        doc="""field With radiobutton input.""",
        widget=widgets.RadioSelect(),
    )
    demo_field2 = models.CharField(
        default=None,
        max_length=5,
        doc="""
        field with text input
        """
    )

    def demo_field1_choices(self):
        return ['0', '1', '2', 'do not know']

    training_question_1 = models.IntegerField(null=True, verbose_name='', widget=widgets.TextInput())
    training_question_2 = models.CharField(max_length=100, null=True, verbose_name='', widget=widgets.RadioSelect())
    training_question_3 = models.CharField(max_length=100, null=True, verbose_name='', widget=widgets.RadioSelect())
    training_question_4 = models.CharField(max_length=100, null=True, verbose_name='', widget=widgets.RadioSelect())
    training_question_5 = models.CharField(max_length=100, null=True, verbose_name='', widget=widgets.RadioSelect())

    def training_question_2_choices(self):
        return ['Embed images', 'Dynamic visualizations using HighCharts', 'Time travel (opens in pop up window)', 'Embed video', 'Embed audio']

    def training_question_3_choices(self):
        return ['Windows', 'Mac OS X', 'iOS', 'Android', 'Any of the above']

    def training_question_4_choices(self):
        return ["Calculation of payoff", "Progress of players through pages", "Values submitted by the players", "Whether players have visited the game", "All of the above"]

    def training_question_5_choices(self):
        return ["Any participants' input/choice", "Time spent on each page", "Invalid attempts from participants", "Answers to understanding questions", "Questionnaire input"]


    def training_question_1_error_message(self, value):
        if value < 0 and abs(value) % 2 == 0:
            return 'Your entry is invalid.'

    # check correct answers
    def is_training_question_1_correct(self):
        return self.training_question_1 == self.subsession.training_1_correct

    def is_training_question_2_correct(self):
        return self.training_question_2 == self.subsession.training_2_correct

    def is_training_question_3_correct(self):
        return self.training_question_3 == self.subsession.training_3_correct

    def is_training_question_4_correct(self):
        return self.training_question_4 == self.subsession.training_4_correct

    def is_training_question_5_correct(self):
        return self.training_question_5 == self.subsession.training_5_correct

    def set_payoff(self):
        self.payoff = 0