|
|
from otree.api import ( |
|
|
models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, |
|
|
Currency as c, currency_range |
|
|
) |
|
|
|
|
|
from random import randint |
|
|
|
|
|
|
|
|
|
|
|
class Constants(BaseConstants): |
|
|
name_in_url = 'Ability_Load_Pilot' |
|
|
players_per_group = None |
|
|
num_rounds = 10 |
|
|
payoff_load = c(0.1) |
|
|
payoff_incorrect = c(0.0) |
|
|
|
|
|
load_string_list = ['56291554', '7749733', '22987883', |
|
|
'8311343', '81174423', '8193613', |
|
|
'9361795', '56424871', '5379763', |
|
|
'45519286'] |
|
|
|
|
|
|
|
|
class Subsession(BaseSubsession): |
|
|
def creating_session(self): |
|
|
|
|
|
for p in self.get_players(): |
|
|
p.payoff = c(0) |
|
|
|
|
|
|
|
|
p.cognitive_load_rand_int = Constants.load_string_list[self.round_number - 1] |
|
|
|
|
|
|
|
|
if self.round_number == 1: |
|
|
p.participant.vars['count_load_correct_ability'] = 0 |
|
|
p.participant.vars['number_rounds_ability_load'] = Constants.num_rounds |
|
|
p.participant.vars['payoff_ability_load'] = Constants.payoff_load |
|
|
|
|
|
|
|
|
class Group(BaseGroup): |
|
|
pass |
|
|
|
|
|
|
|
|
class Player(BasePlayer): |
|
|
|
|
|
app = models.CharField(default='Ability_Load') |
|
|
|
|
|
cognitive_load_rand_int = models.CharField() |
|
|
cognitive_load_entry = models.CharField(blank=True) |
|
|
|
|
|
|
|
|
payoff_load = models.FloatField(default=Constants.payoff_load) |
|
|
payoff_incorrect = models.FloatField(default=Constants.payoff_incorrect) |
|
|
|
|
|
load_correct = models.IntegerField(default=0) |
|
|
|
|
|
def set_payoff(self): |
|
|
|
|
|
if self.cognitive_load_entry == self.cognitive_load_rand_int: |
|
|
self.load_correct = 1 |
|
|
self.payoff = Constants.payoff_load |
|
|
else: |
|
|
self.load_correct = 0 |
|
|
self.payoff = 0 |
|
|
|
|
|
self.participant.vars['count_load_correct_ability'] += self.load_correct |
|
|
|