from otree.api import *
import random
import time
class C(BaseConstants):
NAME_IN_URL = 'Sri_Lanka_2023'
PLAYERS_PER_GROUP = None
NUM_ROUNDS = 10
class Subsession(BaseSubsession):
pass
class Group(BaseGroup):
pass
def make_field_1(label):
return models.IntegerField(widget=widgets.RadioSelect,
label = label,
choices = [
[7, "Everyday සෑම දිනම"],
[6, "Several times a week සතියකට කිහිප වතාවක්"],
[5, "Once a week සතියකට වරක්"],
[4, "Several times a month මසකට කිහිප වතාවක්"],
[3, "Once a month මසකට වරක්"],
[2, "Once in several months මාස කිහිපයකට වරක්"],
[1, "Once in half a year සෑම මාස හයකට වරක්"],
[0, "Once a year වසරකට වරක්"],
]
)
def make_field_2(label):
return models.IntegerField(widget=widgets.RadioSelect,
label = label,
choices = [
[5, "Strongly Agree තරයේ එකඟයි"],
[4, "Agree එකඟයි"],
[3, "Neutral මධ්යස්ථ"],
[2, "Disagree එකඟ නොවේ"],
[1, "Strongly disagree දැඩි ලෙස එකඟ නොවේ"]
]
)
class Player(BasePlayer):
Name = models.StringField(
label = "Name නම"
)
Gender = models.StringField(
choices=[
[0, "Male පිරිමි"],
[1, "Female ගැහැණු"],
[2, "Others අන් අය"],
],
label = "Gender ස්ත්රී පුරුෂ භාවය"
)
Age = models.IntegerField(
label = "Age වයස"
)
Academic_history = models.StringField(
label = "Academic history (Highschool, TVET, Technical Collage etc.) අධ්යයන ඉතිහාසය (උසස් පාසල, TVET, තාක්ෂණික විද්යාල ආදිය)"
)
Marital_status = models.IntegerField(
choices=[
[0, "Single තනිකඩ"],
[1, "Married විවාහක"],
[2, "Prefer not to answer පිළිතුරු නොදීමට කැමති"],
],
label = "Marital status විවාහක අවිවාහක බව"
)
Children = models.IntegerField(
choices=[
[0, "No child ළමයෙක් නැහැ"],
[1, "Have a child/children දරුවෙකු/දරුවන් සිටී"],
[2, "Prefer not to answer පිළිතුරු නොදීමට කැමති"],
],
label = "Children දරුවන්"
)
Institution = models.IntegerField(
choices=[
[0, "National Irrigation Department ජාතික වාරිමාර්ග දෙපාර්තමේන්තුව"],
[1, "Southern Provincial Irrigation Department දකුණු පළාත් වාරිමාර්ග දෙපාර්තමේන්තුව"],
[2, "Western Provincial Irrigation Department බස්නාහිර පළාත් වාරිමාර්ග දෙපාර්තමේන්තුව"],
],
label = "Institution ආයතනය"
)
Area = models.StringField(
label = "Area ප්රදේශය"
)
Post = models.StringField(
label = "Post තනතුර"
)
Num_sub = models.IntegerField(
label = "Number of subordinates යටත් නිලධාරීන් සංඛ්යාව"
)
Name_sup = models.StringField(
label = "Name of engineer ඉංජිනේරුවරයාගේ නම"
)
Name_sub = models.StringField(
label = "Name of subordinates යටත් නිලධාරීන්ගේ නම"
)
Year = models.IntegerField(
label = "Year of becoming a public servant රජයේ සේවකයෙකු වූ වසර"
)
Distance = models.IntegerField()
Freq_sup = make_field_1("Engineer ඉංජිනේරුවරයා")
Freq_sub = make_field_1("Subordinates යටත් නිලධාරීන්")
Freq_col = make_field_1("Colleagues සගයන්")
Freq_cit = make_field_1("Citizens පුරවැසියන්")
Imp_sup = models.StringField(
label = "Engineer ඉංජිනේරුවරයා"
)
Imp_sub = models.StringField(
label = "Subordinates යටත් නිලධාරීන්"
)
Imp_col = models.StringField(
label = "Colleagues සගයන්"
)
Imp_cit = models.StringField(
label = "Citizens පුරවැසියන්"
)
Job_sat = models.IntegerField(
min = 1,
max = 7,
label = ""
)
PSM_1 = make_field_2("Meaningful public service is very important to me.
අර්ථවත් රාජ්ය සේවය මට ඉතා වැදගත්.")
PSM_2 = make_field_2("I am often reminded by daily events about how dependent we are on one another.
අපි එකිනෙකා මත රඳා සිටින ආකාරය ගැන දිනපතා සිදුවීම් මට බොහෝ විට මතක් කර දෙයි.")
PSM_3 = make_field_2("Making a difference in society means more to me than personal achievements.
සමාජයේ වෙනසක් ඇති කිරීම පුද්ගලික ජයග්රහණවලට වඩා මට වැදගත් ය.")
PSM_4 = make_field_2("I am prepared to make enormous sacrifices for the good of society.
සමාජයේ යහපත වෙනුවෙන් දැවැන්ත කැපකිරීම් කිරීමට මම සූදානම්.")
PSM_5 = make_field_2("I am not afraid to go to bat for the rights of others, even if it means I will be ridiculed.
අනුන්ගේ අයිතීන් වෙනුවෙන් පිතිකරණයට යන්න මම බය නැහැ.")
Num = models.IntegerField()
Opinions = models.LongStringField(
blank = True,
label = "Opinions අදහස්"
)
eng_A = models.IntegerField()
issue_A = models.IntegerField()
status_A = models.IntegerField()
past_A = models.IntegerField()
delay_A = models.IntegerField()
budget_A = models.IntegerField()
operator_A = models.IntegerField()
eng_B = models.IntegerField()
issue_B = models.IntegerField()
status_B = models.IntegerField()
past_B = models.IntegerField()
delay_B = models.IntegerField()
budget_B = models.IntegerField()
operator_B = models.IntegerField()
Ans = models.IntegerField(
choices=[
[0, "Issue A ගැටලුව A"],
[1, "Issue B ගැටලුව B"],
],
label="Which issue do you think the engineer should prioritize? ඉංජිනේරුවරයා ප්රමුඛත්වය දිය යුතු යැයි ඔබ සිතන්නේ කුමන ප්රශ්නයටද?"
)
Rate_A = models.IntegerField(
min = 0,
max = 10,
label = "Issue A ගැටලුව A"
)
Rate_B = models.IntegerField(
min = 0,
max = 10,
label = "Issue B ගැටලුව B"
)
Adv = models.IntegerField(
choices=[
[1, "Yes ඔව්"],
[0, "No නැත"],
],
label="If the engineer was going to prioritize the issue you did not select, would you advise him/her to change the priority? ඔබ තෝරා නොගත් ගැටලුවට ඉංජිනේරුවරයා ප්රමුඛත්වය දීමට යන්නේ නම්, ප්රමුඛතාවය වෙනස් කිරීමට ඔබ ඔහුට/ඇයට උපදෙස් දෙනවාද?"
)
def creating_session(subsession):
for player in subsession.get_players():
player.Num = random.randint(0,1)
player.eng_A = random.randint(0,1)
player.issue_A = random.randint(1,5)
player.past_A = random.randint(1,3)
player.delay_A = random.randint(1,3)
player.budget_A = random.randint(1,3)
player.operator_A = random.randint(1,2)
player.eng_B = random.randint(0,1)
player.issue_B = random.randint(1,5)
player.past_B = random.randint(1,3)
player.delay_B = random.randint(1,3)
player.budget_B = random.randint(1,3)
player.operator_B = random.randint(1,2)
# PAGES
class Registration(Page):
@staticmethod
def is_displayed(player):
return player.round_number == 1
form_model = 'player'
form_fields = ['Name', 'Gender', 'Age', 'Academic_history', 'Marital_status', 'Children', 'Institution', 'Area', 'Post', 'Num_sub', 'Name_sup', 'Name_sub', 'Year', 'Distance']
class Basic_info(Page):
@staticmethod
def is_displayed(player):
return player.round_number == 1
form_model = 'player'
form_fields = ['Freq_sup', 'Freq_sub', 'Freq_col', 'Freq_cit', 'Imp_sup', 'Imp_sub', 'Imp_col', 'Imp_cit', 'Job_sat', 'PSM_1', 'PSM_2', 'PSM_3', 'PSM_4', 'PSM_5']
class Opinions(Page):
timeout_seconds = 300
@staticmethod
def is_displayed(player):
return player.Num == 1 and player.round_number == 1
form_model = 'player'
form_fields = {'Opinions'}
class Question(Page):
form_model = 'player'
form_fields = ['Ans', 'Rate_A', 'Rate_B' , 'Adv']
class Checkout(Page):
@staticmethod
def is_displayed(player):
return player.round_number == 10
page_sequence = [Registration, Basic_info, Opinions, Question, Checkout]