from otree.api import *
import random
import math
doc = """
For NoL_6, App containing 2 questionnaires and the demographic survey.
"""
class C(BaseConstants):
NAME_IN_URL = 'questionnaires_nol_6'
PLAYERS_PER_GROUP = None
NUM_ROUNDS = 1
class Subsession(BaseSubsession):
pass
class Group(BaseGroup):
quest_2_selected_answers = models.LongStringField()
class Player(BasePlayer):
quest_1_question_1 = models.StringField(choices=[
[0, 'Very socially inappropriate'], [1, 'Somewhat socially inappropriate'], [2, 'Somewhat socially appropriate'], [3, 'Very socially appropriate'], ], widget=widgets.RadioSelect, label="")
quest_1_matched_questions = models.IntegerField()
quest_1_payoff = models.FloatField(initial=0)
quest_2_question_1 = models.StringField(
choices=[
['a', 'A: $3.0 with 10% chance and $0.1 with 90% chance'],
['b', 'B: $1.5 for sure']
], widget=widgets.RadioSelectHorizontal, label=""
)
quest_2_question_2 = models.StringField(
choices=[
['a', 'A: $3.0 with 20% chance and $0.1 with 80% chance'],
['b', 'B: $1.5 for sure']
], widget=widgets.RadioSelectHorizontal, label=""
)
quest_2_question_3 = models.StringField(
choices=[
['a', 'A: $3.0 with 30% chance and $0.1 with 70% chance'],
['b', 'B: $1.5 for sure']
], widget=widgets.RadioSelectHorizontal, label=""
)
quest_2_question_4 = models.StringField(
choices=[
['a', 'A: $3.0 with 40% chance and $0.1 with 60% chance'],
['b', 'B: $1.5 for sure']
], widget=widgets.RadioSelectHorizontal, label=""
)
quest_2_question_5 = models.StringField(
choices=[
['a', 'A: $3.0 with 50% chance and $0.1 with 50% chance'],
['b', 'B: $1.5 for sure']
], widget=widgets.RadioSelectHorizontal, label=""
)
quest_2_question_6 = models.StringField(
choices=[
['a', 'A: $3.0 with 60% chance and $0.1 with 40% chance'],
['b', 'B: $1.5 for sure']
], widget=widgets.RadioSelectHorizontal, label=""
)
quest_2_question_7 = models.StringField(
choices=[
['a', 'A: $3.0 with 70% chance and $0.1 with 30% chance'],
['b', 'B: $1.5 for sure']
], widget=widgets.RadioSelectHorizontal, label=""
)
quest_2_question_8 = models.StringField(
choices=[
['a', 'A: $3.0 with 80% chance and $0.1 with 20% chance'],
['b', 'B: $1.5 for sure']
], widget=widgets.RadioSelectHorizontal, label=""
)
quest_2_question_9 = models.StringField(
choices=[
['a', 'A: $3.0 with 90% chance and $0.1 with 10% chance'],
['b', 'B: $1.5 for sure']
], widget=widgets.RadioSelectHorizontal, label=""
)
quest_2_question_10 = models.StringField(
choices=[
['a', 'A: $3.0 with 100% chance and $0.1 with 0% chance'],
['b', 'B: $1.5 for sure']
], widget=widgets.RadioSelectHorizontal, label=""
)
quest_2_chosen_question = models.StringField()
quest_2_selection_probability = models.FloatField(initial=0.00)
quest_2_payoff = models.FloatField(initial=0)
# social preference test
quest_3_question_1 = models.IntegerField(
choices=[
[0, 'A: $3.0 to you, $3.0 to other'],
[1, 'B: $3.0 to you, $2.5 to other'],
],
label='Question 1',
widget=widgets.RadioSelectHorizontal
)
quest_3_question_2 = models.IntegerField(
choices=[
[0, 'A: $3.0 to you, $3.0 to other'],
[1, 'B: $3.0 to you, $2.0 to other'],
],
label='Question 2',
widget=widgets.RadioSelectHorizontal
)
quest_3_question_3 = models.IntegerField(
choices=[
[0, 'A: $3.0 to you, $3.0 to other'],
[1, 'B: $3.0 to you, $1.5 to other'],
],
label='Question 3',
widget=widgets.RadioSelectHorizontal
)
quest_3_question_4 = models.IntegerField(
choices=[
[0, 'A: $3.0 to you, $3.0 to other'],
[1, 'B: $2.5 to you, $2.0 to other'],
],
label='Question 4',
widget=widgets.RadioSelectHorizontal
)
quest_3_question_5 = models.IntegerField(
choices=[
[0, 'A: $3.0 to you, $3.0 to other'],
[1, 'B: $2.5 to you, $1.5 to other'],
],
label='Question 5',
widget=widgets.RadioSelectHorizontal
)
quest_3_question_6 = models.IntegerField(
choices=[
[0, 'A: $3.0 to you, $3.0 to other'],
[1, 'B: $2.5 to you, $1.0 to other'],
],
label='Question 6',
widget=widgets.RadioSelectHorizontal
)
quest_3_question_7 = models.IntegerField(
choices=[
[0, 'A: $3.0 to you, $3.0 to other'],
[1, 'B: $3.0 to you, $3.5 to other'],
],
label='Question 7',
widget=widgets.RadioSelectHorizontal
)
quest_3_question_8 = models.IntegerField(
choices=[
[0, 'A: $3.0 to you, $3.0 to other'],
[1, 'B: $3.0 to you, $4.0 to other'],
],
label='Question 8',
widget=widgets.RadioSelectHorizontal
)
quest_3_question_9 = models.IntegerField(
choices=[
[0, 'A: $3.0 to you, $3.0 to other'],
[1, 'B: $3.0 to you, $4.5 to other'],
],
label='Question 9',
widget=widgets.RadioSelectHorizontal
)
quest_3_question_10 = models.IntegerField(
choices=[
[0, 'A: $3.0 to you, $3.0 to other'],
[1, 'B: $3.5 to you, $4.0 to other'],
],
label='Question 10',
widget=widgets.RadioSelectHorizontal
)
quest_3_question_11 = models.IntegerField(
choices=[
[0, 'A: $3.0 to you, $3.0 to other'],
[1, 'B: $3.5 to you, $4.5 to other'],
],
label='Question 11',
widget=widgets.RadioSelectHorizontal
)
quest_3_question_12 = models.IntegerField(
choices=[
[0, 'A: $3.0 to you, $3.0 to other'],
[1, 'B: $3.5 to you, $5.0 to other'],
],
label='Question 12',
widget=widgets.RadioSelectHorizontal
)
quest_3_payoff = models.FloatField(
initial=0,
)
quest_3_chosen_question = models.StringField()
quest_3_chosen_player = models.IntegerField()
quest_4_question_1 = models.IntegerField(
choices=[
[0, 'Try to earn as much money as possible for myself. '],
[1, 'Try to earn as much money as possible for me and my PART 2 group.'],
[2, 'Try to earn more money than my group members.'],
[3, 'Other. Please specify below.'],
],
label='In Part 2 when you were asked to report your die roll outcomes, how would you describe the strategies you used?',
widget=widgets.RadioSelect
)
quest_4_question_1_other = models.LongStringField(blank=True)
g_number = models.StringField(
label="To link with your payments, please type your G number below. Note that your identity will be confidential:")
age = models.IntegerField(label="Age:", min=18, max=100)
gender = models.StringField(
choices=[
['male', 'Male'],
['female', 'Female'],
['other', 'Other'],
], widget=widgets.RadioSelect, label="Gender:"
)
country = models.StringField(
label="Country(s) of citizenship:",)
major = models.StringField(label='Major:',)
year_of_study = models.StringField(
choices=[
['freshman', 'Freshman'],
['sophomore', 'Sophomore'],
['junior', 'Junior'],
['senior', 'Senior'],
['graduate', 'Graduate'],
['other', 'Other'],
], widget=widgets.RadioSelect, label="Which year are you in?",
)
risk_behavior = models.StringField(
choices=[
['0', 'Strongly Disagree'],
['1', 'Disagree'],
['2', 'Slightly Disagree'],
['3', 'Slightly Agree'],
['4', 'Agree'],
['5', 'Strongly Agree'],
], widget=widgets.RadioSelect, label="You are a person who is fully prepared to take risks."
)
trust_people = models.StringField(
choices=[
['1', 'Most people can be trusted'],
['2', 'I need to be very careful in dealing with people'],
], widget=widgets.RadioSelect, label="Generally speaking would you say that most people can be trusted or that you need to be very careful in dealing with people?"
)
comments = models.LongStringField(
label="Do you have any comments, questions or complaints about today's experiment?", blank=True)
participant_match = models.IntegerField(initial=0)
final_payoff = models.CurrencyField()
final_payoff_dollars = models.IntegerField(initial=0)
# PAGES
class last_part_welcome(Page):
@staticmethod
def is_displayed(player: Player):
return player.round_number == 1
class questionnaire_1(Page):
form_model = 'player'
form_fields = ['quest_1_question_1',]
class questionnaire_2(Page):
form_model = 'player'
form_fields = ['quest_2_question_1', 'quest_2_question_2',
'quest_2_question_3', 'quest_2_question_4', 'quest_2_question_5', 'quest_2_question_6', 'quest_2_question_7', 'quest_2_question_8', 'quest_2_question_9', 'quest_2_question_10', ]
def before_next_page(player: Player, timeout_happened):
questions = ['quest_2_question_1', 'quest_2_question_2',
'quest_2_question_3', 'quest_2_question_4', 'quest_2_question_5', 'quest_2_question_6', 'quest_2_question_7', 'quest_2_question_8', 'quest_2_question_9', 'quest_2_question_10', ]
chosen_question_number = random.randint(0, 9)
quest_2_chosen_question = player.quest_2_chosen_question = questions[
chosen_question_number]
if quest_2_chosen_question == 'quest_2_question_1':
if player.quest_2_question_1 == 'a':
quest_2_selection_probability = player.quest_2_selection_probability = round(random.uniform(
0, 1), 4)
if quest_2_selection_probability < 0.1:
player.quest_2_payoff = 6
elif quest_2_selection_probability >= 0.1:
player.quest_2_payoff = 0.2
else:
player.quest_2_payoff = 0
elif player.quest_2_question_1 == 'b':
player.quest_2_payoff = 3
else:
return None
elif quest_2_chosen_question == 'quest_2_question_2':
if player.quest_2_question_2 == 'a':
quest_2_selection_probability = player.quest_2_selection_probability = round(random.uniform(
0, 1), 4)
if quest_2_selection_probability < 0.2:
player.quest_2_payoff = 6
elif quest_2_selection_probability >= 0.2:
player.quest_2_payoff = 0.2
else:
player.quest_2_payoff = 0
elif player.quest_2_question_2 == 'b':
player.quest_2_payoff = 3
else:
return None
elif quest_2_chosen_question == 'quest_2_question_3':
if player.quest_2_question_3 == 'a':
quest_2_selection_probability = player.quest_2_selection_probability = round(random.uniform(
0, 1), 4)
if quest_2_selection_probability < 0.3:
player.quest_2_payoff = 6
elif quest_2_selection_probability >= 0.3:
player.quest_2_payoff = 0.2
else:
player.quest_2_payoff = 0
elif player.quest_2_question_3 == 'b':
player.quest_2_payoff = 3
else:
return None
elif quest_2_chosen_question == 'quest_2_question_4':
if player.quest_2_question_4 == 'a':
quest_2_selection_probability = player.quest_2_selection_probability = round(random.uniform(
0, 1), 4)
if quest_2_selection_probability < 0.4:
player.quest_2_payoff = 6
elif quest_2_selection_probability >= 0.4:
player.quest_2_payoff = 0.2
else:
player.quest_2_payoff = 0
elif player.quest_2_question_4 == 'b':
player.quest_2_payoff = 3
else:
return None
elif quest_2_chosen_question == 'quest_2_question_5':
if player.quest_2_question_5 == 'a':
quest_2_selection_probability = player.quest_2_selection_probability = round(random.uniform(
0, 1), 4)
if quest_2_selection_probability < 0.5:
player.quest_2_payoff = 6
elif quest_2_selection_probability >= 0.5:
player.quest_2_payoff = 0.2
else:
player.quest_2_payoff = 0
elif player.quest_2_question_5 == 'b':
player.quest_2_payoff = 3
else:
return None
elif quest_2_chosen_question == 'quest_2_question_6':
if player.quest_2_question_6 == 'a':
quest_2_selection_probability = player.quest_2_selection_probability = round(random.uniform(
0, 1), 4)
if quest_2_selection_probability < 0.6:
player.quest_2_payoff = 6
elif quest_2_selection_probability >= 0.6:
player.quest_2_payoff = 0.2
else:
player.quest_2_payoff = 0
elif player.quest_2_question_6 == 'b':
player.quest_2_payoff = 3
else:
return None
elif quest_2_chosen_question == 'quest_2_question_7':
if player.quest_2_question_7 == 'a':
quest_2_selection_probability = player.quest_2_selection_probability = round(random.uniform(
0, 1), 4)
if quest_2_selection_probability < 0.7:
player.quest_2_payoff = 6
elif quest_2_selection_probability >= 0.7:
player.quest_2_payoff = 0.2
else:
player.quest_2_payoff = 0
elif player.quest_2_question_7 == 'b':
player.quest_2_payoff = 3
else:
return None
elif quest_2_chosen_question == 'quest_2_question_8':
if player.quest_2_question_8 == 'a':
quest_2_selection_probability = player.quest_2_selection_probability = round(random.uniform(
0, 1), 4)
if quest_2_selection_probability < 0.8:
player.quest_2_payoff = 6
elif quest_2_selection_probability >= 0.8:
player.quest_2_payoff = 0.2
else:
player.quest_2_payoff = 0
elif player.quest_2_question_8 == 'b':
player.quest_2_payoff = 3
else:
return None
elif quest_2_chosen_question == 'quest_2_question_9':
if player.quest_2_question_9 == 'a':
quest_2_selection_probability = player.quest_2_selection_probability = round(random.uniform(
0, 1), 4)
if quest_2_selection_probability < 0.9:
player.quest_2_payoff = 6
elif quest_2_selection_probability >= 0.9:
player.quest_2_payoff = 0.2
else:
player.quest_2_payoff = 0
elif player.quest_2_question_9 == 'b':
player.quest_2_payoff = 3
else:
return None
elif quest_2_chosen_question == 'quest_2_question_10':
if player.quest_2_question_10 == 'a':
quest_2_selection_probability = player.quest_2_selection_probability = round(random.uniform(
0, 1), 4)
if quest_2_selection_probability < 1.0:
player.quest_2_payoff = 6
elif quest_2_selection_probability >= 1.0:
player.quest_2_payoff = 0.2
else:
player.quest_2_payoff = 0
elif player.quest_2_question_10 == 'b':
player.quest_2_payoff = 3
else:
return None
else:
return None
class questionnaire_3(Page):
form_model = 'player'
form_fields = ['quest_3_question_1', 'quest_3_question_2',
'quest_3_question_3', 'quest_3_question_4', 'quest_3_question_5', 'quest_3_question_6', 'quest_3_question_7', 'quest_3_question_8', 'quest_3_question_9', 'quest_3_question_10', 'quest_3_question_11', 'quest_3_question_12',]
class demographic_survey(Page):
form_model = 'player'
form_fields = ['g_number', 'age', 'gender', 'country', 'major',
'year_of_study', 'quest_4_question_1', 'quest_4_question_1_other', 'risk_behavior', 'trust_people', 'comments']
class ResultsWaitPage(WaitPage):
def after_all_players_arrive(group: Group):
all_players = group.subsession.get_players()
for i in range(0, len(all_players)):
while all_players[i].participant_match == 0:
random_participant_match = random.randint(
0, len(all_players)-1)
if all_players[random_participant_match].participant_match == 0 and i != random_participant_match:
all_players[i].participant_match = random_participant_match+1
all_players[random_participant_match].participant_match = i+1
else:
continue
# ASK THIS: Should the questions be from different tables for random selection or 2 questions from 1 table is okay????
# Check for Questionnaire-1&2
quest_3_questions = ['quest_3_question_1', 'quest_3_question_2',
'quest_3_question_3', 'quest_3_question_4', 'quest_3_question_5', 'quest_3_question_6', 'quest_3_question_7', 'quest_3_question_8', 'quest_3_question_9', 'quest_3_question_10', 'quest_3_question_11', 'quest_3_question_12',]
for x in range(0, len(all_players)):
player_x = all_players[x]
player_match_x = group.get_player_by_id(
player_x.participant_match)
quest_1_payoff_temp = 0
if player_x.quest_1_question_1 == player_match_x.quest_1_question_1:
quest_1_payoff_temp += 1
player_x.quest_1_matched_questions = player_match_x.quest_1_matched_questions = quest_1_payoff_temp
player_x.quest_1_payoff += quest_1_payoff_temp/2
player_match_x.quest_1_payoff += quest_1_payoff_temp/2
if not (player_x.field_maybe_none("quest_3_chosen_question") and player_match_x.field_maybe_none("quest_3_chosen_question")):
quest_3_chosen_question_number = random.randint(0, 11)
player_x.quest_3_chosen_question = player_match_x.quest_3_chosen_question = quest_3_questions[
quest_3_chosen_question_number]
quest_3_chosen_player = random.randint(0, 1)
player_x.quest_3_chosen_player = player_match_x.quest_3_chosen_player = quest_3_chosen_player
if player_x.quest_3_payoff == 0 and player_match_x.quest_3_payoff == 0:
if quest_3_chosen_player == 0:
if player_x.quest_3_chosen_question == quest_3_questions[0]:
if player_x.quest_3_question_1 == 0:
player_x.quest_3_payoff = 6
player_match_x.quest_3_payoff = 6
elif player_x.quest_3_question_1 == 1:
player_x.quest_3_payoff = 6
player_match_x.quest_3_payoff = 5
else:
player_x.quest_3_payoff = 0
player_match_x.quest_3_payoff = 0
elif player_x.quest_3_chosen_question == quest_3_questions[1]:
if player_x.quest_3_question_2 == 0:
player_x.quest_3_payoff = 6
player_match_x.quest_3_payoff = 6
elif player_x.quest_3_question_2 == 1:
player_x.quest_3_payoff = 6
player_match_x.quest_3_payoff = 4
else:
player_x.quest_3_payoff = 0
player_match_x.quest_3_payoff = 0
elif player_x.quest_3_chosen_question == quest_3_questions[2]:
if player_x.quest_3_question_3 == 0:
player_x.quest_3_payoff = 6
player_match_x.quest_3_payoff = 6
elif player_x.quest_3_question_3 == 1:
player_x.quest_3_payoff = 6
player_match_x.quest_3_payoff = 3
else:
player_x.quest_3_payoff = 0
player_match_x.quest_3_payoff = 0
elif player_x.quest_3_chosen_question == quest_3_questions[3]:
if player_x.quest_3_question_4 == 0:
player_x.quest_3_payoff = 6
player_match_x.quest_3_payoff = 6
elif player_x.quest_3_question_4 == 1:
player_x.quest_3_payoff = 5
player_match_x.quest_3_payoff = 4
else:
player_x.quest_3_payoff = 0
player_match_x.quest_3_payoff = 0
elif player_x.quest_3_chosen_question == quest_3_questions[4]:
if player_x.quest_3_question_5 == 0:
player_x.quest_3_payoff = 6
player_match_x.quest_3_payoff = 6
elif player_x.quest_3_question_5 == 1:
player_x.quest_3_payoff = 5
player_match_x.quest_3_payoff = 3
else:
player_x.quest_3_payoff = 0
player_match_x.quest_3_payoff = 0
elif player_x.quest_3_chosen_question == quest_3_questions[5]:
if player_x.quest_3_question_6 == 0:
player_x.quest_3_payoff = 6
player_match_x.quest_3_payoff = 6
elif player_x.quest_3_question_6 == 1:
player_x.quest_3_payoff = 5
player_match_x.quest_3_payoff = 2
else:
player_x.quest_3_payoff = 0
player_match_x.quest_3_payoff = 0
elif player_x.quest_3_chosen_question == quest_3_questions[6]:
if player_x.quest_3_question_7 == 0:
player_x.quest_3_payoff = 6
player_match_x.quest_3_payoff = 6
elif player_x.quest_3_question_7 == 1:
player_x.quest_3_payoff = 6
player_match_x.quest_3_payoff = 7
else:
player_x.quest_3_payoff = 0
player_match_x.quest_3_payoff = 0
elif player_x.quest_3_chosen_question == quest_3_questions[7]:
if player_x.quest_3_question_8 == 0:
player_x.quest_3_payoff = 6
player_match_x.quest_3_payoff = 6
elif player_x.quest_3_question_8 == 1:
player_x.quest_3_payoff = 6
player_match_x.quest_3_payoff = 8
else:
player_x.quest_3_payoff = 0
player_match_x.quest_3_payoff = 0
elif player_x.quest_3_chosen_question == quest_3_questions[8]:
if player_x.quest_3_question_9 == 0:
player_x.quest_3_payoff = 6
player_match_x.quest_3_payoff = 6
elif player_x.quest_3_question_9 == 1:
player_x.quest_3_payoff = 6
player_match_x.quest_3_payoff = 9
else:
player_x.quest_3_payoff = 0
player_match_x.quest_3_payoff = 0
elif player_x.quest_3_chosen_question == quest_3_questions[9]:
if player_x.quest_3_question_10 == 0:
player_x.quest_3_payoff = 6
player_match_x.quest_3_payoff = 6
elif player_x.quest_3_question_10 == 1:
player_x.quest_3_payoff = 7
player_match_x.quest_3_payoff = 8
else:
player_x.quest_3_payoff = 0
player_match_x.quest_3_payoff = 0
elif player_x.quest_3_chosen_question == quest_3_questions[10]:
if player_x.quest_3_question_11 == 0:
player_x.quest_3_payoff = 6
player_match_x.quest_3_payoff = 6
elif player_x.quest_3_question_11 == 1:
player_x.quest_3_payoff = 7
player_match_x.quest_3_payoff = 9
else:
player_x.quest_3_payoff = 0
player_match_x.quest_3_payoff = 0
elif player_x.quest_3_chosen_question == quest_3_questions[11]:
if player_x.quest_3_question_12 == 0:
player_x.quest_3_payoff = 6
player_match_x.quest_3_payoff = 6
elif player_x.quest_3_question_12 == 1:
player_x.quest_3_payoff = 7
player_match_x.quest_3_payoff = 10
else:
player_x.quest_3_payoff = 0
player_match_x.quest_3_payoff = 0
else:
player_x.quest_3_payoff = 0
player_match_x.quest_3_payoff = 0
elif quest_3_chosen_player == 1:
if player_match_x.quest_3_chosen_question == quest_3_questions[0]:
if player_x.quest_3_question_1 == 0:
player_x.quest_3_payoff = 6
player_match_x.quest_3_payoff = 6
elif player_x.quest_3_question_1 == 1:
player_x.quest_3_payoff = 6
player_match_x.quest_3_payoff = 5
else:
player_x.quest_3_payoff = 0
player_match_x.quest_3_payoff = 0
elif player_match_x.quest_3_chosen_question == quest_3_questions[1]:
if player_match_x.quest_3_question_1 == 0:
player_x.quest_3_payoff = 6
player_match_x.quest_3_payoff = 6
elif player_match_x.quest_3_question_1 == 1:
player_x.quest_3_payoff = 4
player_match_x.quest_3_payoff = 6
else:
player_x.quest_3_payoff = 0
player_match_x.quest_3_payoff = 0
elif player_match_x.quest_3_chosen_question == quest_3_questions[2]:
if player_match_x.quest_3_question_3 == 0:
player_x.quest_3_payoff = 6
player_match_x.quest_3_payoff = 6
elif player_match_x.quest_3_question_3 == 1:
player_x.quest_3_payoff = 3
player_match_x.quest_3_payoff = 6
else:
player_x.quest_3_payoff = 0
player_match_x.quest_3_payoff = 0
elif player_match_x.quest_3_chosen_question == quest_3_questions[3]:
if player_match_x.quest_3_question_4 == 0:
player_x.quest_3_payoff = 6
player_match_x.quest_3_payoff = 6
elif player_match_x.quest_3_question_4 == 1:
player_x.quest_3_payoff = 4
player_match_x.quest_3_payoff = 5
else:
player_x.quest_3_payoff = 0
player_match_x.quest_3_payoff = 0
elif player_match_x.quest_3_chosen_question == quest_3_questions[4]:
if player_match_x.quest_3_question_5 == 0:
player_x.quest_3_payoff = 6
player_match_x.quest_3_payoff = 6
elif player_match_x.quest_3_question_5 == 1:
player_x.quest_3_payoff = 3
player_match_x.quest_3_payoff = 5
else:
player_x.quest_3_payoff = 0
player_match_x.quest_3_payoff = 0
elif player_match_x.quest_3_chosen_question == quest_3_questions[5]:
if player_match_x.quest_3_question_6 == 0:
player_x.quest_3_payoff = 6
player_match_x.quest_3_payoff = 6
elif player_match_x.quest_3_question_6 == 1:
player_x.quest_3_payoff = 2
player_match_x.quest_3_payoff = 5
else:
player_x.quest_3_payoff = 0
player_match_x.quest_3_payoff = 0
elif player_match_x.quest_3_chosen_question == quest_3_questions[6]:
if player_match_x.quest_3_question_7 == 0:
player_x.quest_3_payoff = 6
player_match_x.quest_3_payoff = 6
elif player_match_x.quest_3_question_7 == 1:
player_x.quest_3_payoff = 7
player_match_x.quest_3_payoff = 6
else:
player_x.quest_3_payoff = 0
player_match_x.quest_3_payoff = 0
elif player_match_x.quest_3_chosen_question == quest_3_questions[7]:
if player_match_x.quest_3_question_8 == 0:
player_x.quest_3_payoff = 6
player_match_x.quest_3_payoff = 6
elif player_match_x.quest_3_question_8 == 1:
player_x.quest_3_payoff = 8
player_match_x.quest_3_payoff = 6
else:
player_x.quest_3_payoff = 0
player_match_x.quest_3_payoff = 0
elif player_match_x.quest_3_chosen_question == quest_3_questions[8]:
if player_match_x.quest_3_question_9 == 0:
player_x.quest_3_payoff = 6
player_match_x.quest_3_payoff = 6
elif player_match_x.quest_3_question_9 == 1:
player_x.quest_3_payoff = 9
player_match_x.quest_3_payoff = 6
else:
player_x.quest_3_payoff = 0
player_match_x.quest_3_payoff = 0
elif player_match_x.quest_3_chosen_question == quest_3_questions[9]:
if player_match_x.quest_3_question_10 == 0:
player_x.quest_3_payoff = 6
player_match_x.quest_3_payoff = 6
elif player_match_x.quest_3_question_10 == 1:
player_x.quest_3_payoff = 8
player_match_x.quest_3_payoff = 7
else:
player_x.quest_3_payoff = 0
player_match_x.quest_3_payoff = 0
elif player_match_x.quest_3_chosen_question == quest_3_questions[10]:
if player_match_x.quest_3_question_11 == 0:
player_x.quest_3_payoff = 6
player_match_x.quest_3_payoff = 6
elif player_match_x.quest_3_question_11 == 1:
player_x.quest_3_payoff = 9
player_match_x.quest_3_payoff = 7
else:
player_x.quest_3_payoff = 0
player_match_x.quest_3_payoff = 0
elif player_match_x.quest_3_chosen_question == quest_3_questions[11]:
if player_match_x.quest_3_question_12 == 0:
player_x.quest_3_payoff = 6
player_match_x.quest_3_payoff = 6
elif player_match_x.quest_3_question_12 == 1:
player_x.quest_3_payoff = 10
player_match_x.quest_3_payoff = 7
else:
player_x.quest_3_payoff = 0
player_match_x.quest_3_payoff = 0
else:
player_x.quest_3_payoff = 0
player_match_x.quest_3_payoff = 0
else:
player_x.quest_3_payoff = 0
player_match_x.quest_3_payoff = 0
class Results(Page):
def vars_for_template(player: Player):
part_1_payoff = cu(player.participant.part_1_payoff)
payoff_round = player.participant.payoff_round
part_2_payoff = cu(player.participant.part_2_payoff)
quest_1_matched_questions = player.quest_1_matched_questions
part_4_payoff_quest_1 = cu(player.quest_1_payoff)
part_4_payoff_quest_3 = cu(player.quest_2_payoff)
quest_2_chosen_question = (
player.quest_2_chosen_question.replace("_", " ")).title()[7:]
part_4_payoff_quest_4 = cu(player.quest_3_payoff)
quest_3_chosen_question = (
player.quest_3_chosen_question.replace("_", " ")).title()[7:]
player.final_payoff = (part_1_payoff + part_2_payoff +
player.quest_1_payoff + player.quest_2_payoff + player.quest_3_payoff)
player.participant.payoff = cu(player.final_payoff)
player.final_payoff_dollars = math.ceil(
player.participant.payoff_plus_participation_fee())
return {
'part_1_payoff': part_1_payoff.to_real_world_currency(player.session),
'part_2_payoff': part_2_payoff.to_real_world_currency(player.session),
'payoff_round': payoff_round,
'quest_1_matched_questions': quest_1_matched_questions,
'part_4_payoff_quest_1': part_4_payoff_quest_1.to_real_world_currency(player.session),
'part_4_payoff_quest_3': part_4_payoff_quest_3.to_real_world_currency(player.session),
'part_4_payoff_quest_4': part_4_payoff_quest_4.to_real_world_currency(player.session),
'quest_2_chosen_question': quest_2_chosen_question,
'quest_3_chosen_question': quest_3_chosen_question,
'final_payoff_dollars': player.final_payoff_dollars,
}
class finished_questionnaires(Page):
pass
page_sequence = [last_part_welcome, questionnaire_1, questionnaire_2, questionnaire_3,
finished_questionnaires, demographic_survey, ResultsWaitPage, Results]