from otree.api import (
models,
widgets,
BaseConstants,
BaseSubsession,
BaseGroup,
BasePlayer,
Currency as c,
currency_range,
)
import itertools
import random
author = 'Your name here'
doc = """
Your app description
"""
class Constants(BaseConstants):
name_in_url = 'sp_task_description'
players_per_group = None
num_rounds = 1
class Subsession(BaseSubsession):
def creating_session(self):
treatment = itertools.cycle([
't_none', #No interaction
't_one', #One-way interaction
't_two' #Two-way interaction
])
for p in self.get_players():
#p.participant.vars['treatment'] = self.session.config['treatment'] #Use this if treatment is defined by session conifg
p.participant.vars['treatment'] = next(treatment) #Use this if treatment is defined here in models.py
p.treatment = p.participant.vars['treatment']
p.participant.vars['quiz_successful'] = False #Initially we set this variable flase. As soon as the quizz is completed, this is set to TRUE
#Determine the order of the products to forecast
p.participant.vars['number_products'] = 50
p.participant.vars['number_periods_historic_demand'] = 30
product_order = []
for r in range(1,p.participant.vars['number_products']+1):
product_order.append(r)
#random.shuffle(product_order) #uncomment this if product order should be randomized
p.participant.vars['product_order'] = product_order
p.product_order = str(product_order)
print('Participant ID in subsession: ' + str(p.id_in_subsession) + '| Treatment: ' + p.participant.vars['treatment'] + '\t | Surgery Order: ' + str(product_order))
class Group(BaseGroup):
pass
class Player(BasePlayer):
treatment = models.StringField()
product_order = models.StringField()
Q1 = models.StringField(
label='All else equal, you should expect a surgery to have a longer duration if it has higher procedure set-up requirements.',
widget=widgets.RadioSelect)
def Q1_choices(self):
choices = [[1, 'True'],
[2, 'False']]
random.shuffle(choices)
return choices
Q2 = models.StringField(
label='All else equal, you should expect the surgery to have a longer duration if it requires more complex anesthesia.',
widget=widgets.RadioSelect)
def Q2_choices(self):
choices = [[1, 'True'],
[2, 'False']]
random.shuffle(choices)
return choices
Q3 = models.StringField(
label='All else equal, you should expect the surgery to have a longer duration if it has higher anesthesia set-up requirements.',
widget=widgets.RadioSelect)
def Q3_choices(self):
choices = [[1, 'True'],
[2, 'False']]
random.shuffle(choices)
return choices
Q4 = models.StringField(
label='Please compare the two surgeries below:
Surgery I:
1. Number of procedure requirements (0 = least, 10 = highest): 5
2. Your assessment of anesthesia complexity (-5 = least complex, 5 = most complex): 3.2
3. Number of anesthesia set-up requirements (0 = least, 10 = highest): 7
Surgery II
1. Number of procedure set-up requirements (0 = least, 10 = highest): 3
2. Your assessment of anesthesia complexity (-5 = least complex, 5 = most complex): -1.2
3. Number of anesthesia set-up requirements (0 = least, 10 = highest): 0
Which surgery below should you expect to take longer ?',
widget=widgets.RadioSelect)
def Q4_choices(self):
choices = [[1, 'Surgery I'],
[2, 'Surgery II']]
return choices