from otree.api import * doc = """ Your app description """ class C(BaseConstants): # Duration of the task Game_Time = 45 NAME_IN_URL = 'matrix_reasoning' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 TIMER_TEXT = "Time left:" # --- bomb game setting --- # # value of single collected box # if the bomb is not collected, player's payoff per round is determined by times # note that the currency of any earnings is determined by the oTree settings in settings.py # if you set this to a decimal number, you must set POINTS_DECIMAL_PLACES in settings.py BOX_VALUE = 1 NUM_ROWS = 5 NUM_COLS = 5 # make sure that the size of the boxes fits the screen of the device # note that the layout is responsive, i.e. boxes will break into new rows if they don't fit BOX_HEIGHT = '50px' BOX_WIDTH = '50px' # determines whether all rounds played are payed-off or whether one round is randomly chosen for payment # if , one round is randomly determined for payment # if , the final payoff of the task is the sum of all rounds played # note that this is only of interest for the case of larger than 1 RANDOM_PAYOFF = True # if , a separate template "Instructions.html" is rendered prior to the task in round 1 # if , the task starts immediately (e.g. in case of printed instructions) INSTRUCTIONS = True # show feedback by resolving boxes, i.e. toggle boxes and show whether bomb was collected or not # if , the button "Solve" will be rendered and active after game play ends ("Stop") # if , the button "Solve" won't be rendered such that no feedback about game outcome is provided FEEDBACK = True # show results page summarizing the game outcome # if , a separate page containing all relevant information is displayed after finishing the task # if larger than 1, results are summarized in a table and only shown after all rounds have been played RESULTS = True # --- Settings Determining Game Play --- # # "dynamic" or "static" game play # if , one box per time interval is collected automatically # in case of , game play is affected by the variables and below # if , subjects collect as many boxes as they want by clicking or entering the respective number # in case of , game play is affected by the variables , and DYNAMIC = False # time interval between single boxes being collected (in seconds) # note that this only affects game play if TIME_INTERVAL = 1.00 # collect boxes randomly or systematically # if , boxes are collected row-wise one-by-one, starting in the top-left corner # if , boxes are collected randomly (Fisher-Yates Algorithm) # note that this affects game play in both cases, and RANDOM = True # determines whether static game play allows for selecting boxes by clicking or by entering a number # if , game play is similar to Slovic (1965), i.e. boxes are collected by subjects # if , subjects enter the number of boxes they want to collect # note that this only affects game play if DEVILS_GAME = True # determine whether boxes can be toggled only once or as often as clicked # if boxes can be selected and de-selected indefinitely often # if boxes can be selected only once (i.e. decisions can not be undone) # note that this only affects game play if and UNDOABLE = True NUM_BOXES = NUM_ROWS * NUM_COLS class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): # Parameter in Practice Rounds success_practice_small = models.IntegerField(initial=0) count_practice_small = models.IntegerField(initial=0) success_practice_big = models.IntegerField(initial=0) count_practice_big = models.IntegerField(initial=0) # Task_Choice TaskChoice_R2 = models.IntegerField(widget=widgets.RadioSelect, choices=[[1, 'Small gird [3×3, receive 1 token if work out the task]'], [2, 'Big grid [5×5, receive 4 tokens if work out the task]']]) TaskChoice_R3 = models.IntegerField(widget=widgets.RadioSelect, choices=[[1, 'Small gird [3×3, receive 1 token if work out the task]'], [2, 'Big grid [5×5, receive 4 tokens if work out the task]']]) TaskChoice_R4 = models.IntegerField(widget=widgets.RadioSelect, choices=[[1, 'Small gird [3×3, receive 1 token if work out the task]'], [2, 'Big grid [5×5, receive 4 tokens if work out the task]']]) TaskChoice_R5 = models.IntegerField(widget=widgets.RadioSelect, choices=[[1, 'Small gird [3×3, receive 1 token if work out the task]'], [2, 'Big grid [5×5, receive 4 tokens if work out the task]']]) TaskChoice_R6 = models.IntegerField(widget=widgets.RadioSelect, choices=[[1, 'Small gird [3×3, receive 1 token if work out the task]'], [2, 'Big grid [5×5, receive 4 tokens if work out the task]']]) TaskChoice_R7 = models.IntegerField(widget=widgets.RadioSelect, choices=[[1, 'Small gird [3×3, receive 1 token if work out the task]'], [2, 'Big grid [5×5, receive 4 tokens if work out the task]']]) TaskChoice_R8 = models.IntegerField(widget=widgets.RadioSelect, choices=[[1, 'Small gird [3×3, receive 1 token if work out the task]'], [2, 'Big grid [5×5, receive 4 tokens if work out the task]']]) TaskChoice_R9 = models.IntegerField(widget=widgets.RadioSelect, choices=[[1, 'Small gird [3×3, receive 1 token if work out the task]'], [2, 'Big grid [5×5, receive 4 tokens if work out the task]']]) TaskChoice_R10 = models.IntegerField(widget=widgets.RadioSelect, choices=[[1, 'Small gird [3×3, receive 1 token if work out the task]'], [2, 'Big grid [5×5, receive 4 tokens if work out the task]']]) TaskChoice_big = models.IntegerField(initial=0) TaskChoice_small = models.IntegerField(initial=0) # Parameter in Formal Rounds success_R2_small = models.IntegerField(initial=0) count_R2_small = models.IntegerField(initial=0) success_R3_small = models.IntegerField(initial=0) count_R3_small = models.IntegerField(initial=0) success_R4_small = models.IntegerField(initial=0) count_R4_small = models.IntegerField(initial=0) success_R5_small = models.IntegerField(initial=0) count_R5_small = models.IntegerField(initial=0) success_R6_small = models.IntegerField(initial=0) count_R6_small = models.IntegerField(initial=0) success_R7_small = models.IntegerField(initial=0) count_R7_small = models.IntegerField(initial=0) success_R8_small = models.IntegerField(initial=0) count_R8_small = models.IntegerField(initial=0) success_R9_small = models.IntegerField(initial=0) count_R9_small = models.IntegerField(initial=0) success_R10_small = models.IntegerField(initial=0) count_R10_small = models.IntegerField(initial=0) success_R1_big = models.IntegerField(initial=0) count_R1_big = models.IntegerField(initial=0) success_R2_big = models.IntegerField(initial=0) count_R2_big = models.IntegerField(initial=0) success_R3_big = models.IntegerField(initial=0) count_R3_big = models.IntegerField(initial=0) success_R4_big = models.IntegerField(initial=0) count_R4_big = models.IntegerField(initial=0) success_R5_big = models.IntegerField(initial=0) count_R5_big = models.IntegerField(initial=0) success_R6_big = models.IntegerField(initial=0) count_R6_big = models.IntegerField(initial=0) success_R7_big = models.IntegerField(initial=0) count_R7_big = models.IntegerField(initial=0) success_R8_big = models.IntegerField(initial=0) count_R8_big = models.IntegerField(initial=0) success_R9_big = models.IntegerField(initial=0) count_R9_big = models.IntegerField(initial=0) success_R10_big = models.IntegerField(initial=0) count_R10_big = models.IntegerField(initial=0) # Tokens Earned in Task 1 payoff_R1_big = models.IntegerField(initial=0) payoff_R2_big = models.IntegerField(initial=0) payoff_R3_big = models.IntegerField(initial=0) payoff_R4_big = models.IntegerField(initial=0) payoff_R5_big = models.IntegerField(initial=0) payoff_R6_big = models.IntegerField(initial=0) payoff_R7_big = models.IntegerField(initial=0) payoff_R8_big = models.IntegerField(initial=0) payoff_R9_big = models.IntegerField(initial=0) payoff_R10_big = models.IntegerField(initial=0) payoff_R2_small = models.IntegerField(initial=0) payoff_R3_small = models.IntegerField(initial=0) payoff_R4_small = models.IntegerField(initial=0) payoff_R5_small = models.IntegerField(initial=0) payoff_R6_small = models.IntegerField(initial=0) payoff_R7_small = models.IntegerField(initial=0) payoff_R8_small = models.IntegerField(initial=0) payoff_R9_small = models.IntegerField(initial=0) payoff_R10_small = models.IntegerField(initial=0) payoff_task1 = models.IntegerField(initial=0) # Time Spent in each round time_R1_begin = models.IntegerField(initial=0) time_R1_end = models.IntegerField(initial=0) time_R1 = models.IntegerField(initial=0) time_R2_begin = models.IntegerField(initial=0) time_R2_end = models.IntegerField(initial=0) time_R2 = models.IntegerField(initial=0) time_R3_begin = models.IntegerField(initial=0) time_R3_end = models.IntegerField(initial=0) time_R3 = models.IntegerField(initial=0) time_R4_begin = models.IntegerField(initial=0) time_R4_end = models.IntegerField(initial=0) time_R4 = models.IntegerField(initial=0) time_R5_begin = models.IntegerField(initial=0) time_R5_end = models.IntegerField(initial=0) time_R5 = models.IntegerField(initial=0) time_R6_begin = models.IntegerField(initial=0) time_R6_end = models.IntegerField(initial=0) time_R6 = models.IntegerField(initial=0) time_R7_begin = models.IntegerField(initial=0) time_R7_end = models.IntegerField(initial=0) time_R7 = models.IntegerField(initial=0) time_R8_begin = models.IntegerField(initial=0) time_R8_end = models.IntegerField(initial=0) time_R8 = models.IntegerField(initial=0) time_R9_begin = models.IntegerField(initial=0) time_R9_end = models.IntegerField(initial=0) time_R9 = models.IntegerField(initial=0) time_R10_begin = models.IntegerField(initial=0) time_R10_end = models.IntegerField(initial=0) time_R10 = models.IntegerField(initial=0) # whether bomb is collected or not # store as integer because it's easier for interop with JS bomb = models.IntegerField() bomb_row = models.IntegerField() bomb_col = models.IntegerField() boxes_collected = models.IntegerField() pay_this_round = models.BooleanField() result = models.IntegerField() Gender = models.IntegerField(widget=widgets.RadioSelect, choices=[[1, 'Male'], [2, 'Female']]) Grade = models.IntegerField(widget=widgets.RadioSelect, choices=[[1, 'Grade 7'], [2, 'Grade 8']]) Student_ID = models.IntegerField() Class = models.StringField() School = models.StringField() total_payoff = models.IntegerField() # FUNCTIONS def set_payoff(player: Player): # determine round_result as (potential) payoff per round if player.bomb: player.result = 0 else: player.result = player.boxes_collected * C.BOX_VALUE # PAGES class General_Instructions(Page): pass class Instruction_Task1(Page): pass class Practice(Page): pass class Practice_Small(Page): form_model = 'player' @staticmethod def live_method(player, data): if 'foundPairs' in data: player.count_practice_small = data['foundPairs'] if 'success_practice_small' in data: player.success_practice_small = data['success_practice_small'] class Practice_Big(Page): form_model = 'player' @staticmethod def live_method(player, data): if 'foundPairs' in data: player.count_practice_big = data['foundPairs'] if 'success_practice_big' in data: player.success_practice_big = data['success_practice_big'] class Task1(Page): pass class Task1_R1(Page): form_model = 'player' timer_text = C.TIMER_TEXT timeout_seconds = C.Game_Time @staticmethod def vars_for_template(player): import time player.time_R1_begin = int(time.time()) @staticmethod def live_method(player, data): if 'foundPairs' in data: player.count_R1_big = data['foundPairs'] if 'success_practice_big' in data: player.success_R1_big = data['success_R1_big'] @staticmethod def before_next_page(player: Player, timeout_happened): import time player.time_R1_end = int(time.time()) player.time_R1 = player.time_R1_end - player.time_R1_begin class Result_R1(Page): @staticmethod def before_next_page(player: Player, timeout_happened): if player.count_R1_big > 2: player.payoff_R1_big = 4 else: player.payoff_R1_big = 0 player.TaskChoice_big += 1 class Task_Assignment_R2(Page): form_model = 'player' form_fields = ['TaskChoice_R2'] class Task1_R2(Page): form_model = 'player' timer_text = C.TIMER_TEXT timeout_seconds = C.Game_Time @staticmethod def vars_for_template(player): import time player.time_R2_begin = int(time.time()) @staticmethod def live_method(player, data): # If the small grid is chosen if player.TaskChoice_R2 == 1 and 'foundPairs' in data: player.count_R2_small = data['foundPairs'] if player.TaskChoice_R2 == 1 and 'success_practice_small' in data: player.success_R2_small = data['success_R2_small'] # If the big grid is chosen if player.TaskChoice_R2 == 2 and 'foundPairs' in data: player.count_R2_big = data['foundPairs'] if player.TaskChoice_R2 == 2 and 'success_practice_big' in data: player.success_R2_big = data['success_R2_big'] @staticmethod def before_next_page(player: Player, timeout_happened): import time player.time_R2_end = int(time.time()) player.time_R2 = player.time_R2_end - player.time_R2_begin class Result_R2(Page): @staticmethod def before_next_page(player: Player, timeout_happened): if player.count_R2_big > 2: player.payoff_R2_big = 4 else: player.payoff_R2_big = 0 if player.count_R2_small > 2: player.payoff_R2_small = 1 else: player.payoff_R2_small = 0 if player.TaskChoice_R2 == 1: player.TaskChoice_small += 1 else: player.TaskChoice_big += 1 class Task_Assignment_R3(Page): form_model = 'player' form_fields = ['TaskChoice_R3'] class Task1_R3(Page): form_model = 'player' timer_text = C.TIMER_TEXT timeout_seconds = C.Game_Time @staticmethod def vars_for_template(player): import time player.time_R3_begin = int(time.time()) @staticmethod def live_method(player, data): # If the small grid is chosen if player.TaskChoice_R3 == 1 and 'foundPairs' in data: player.count_R3_small = data['foundPairs'] if player.TaskChoice_R3 == 1 and 'success_practice_small' in data: player.success_R3_small = data['success_R3_small'] # If the big grid is chosen if player.TaskChoice_R3 == 2 and 'foundPairs' in data: player.count_R3_big = data['foundPairs'] if player.TaskChoice_R3 == 2 and 'success_practice_big' in data: player.success_R3_big = data['success_R3_big'] @staticmethod def before_next_page(player: Player, timeout_happened): import time player.time_R3_end = int(time.time()) player.time_R3 = player.time_R3_end - player.time_R3_begin class Result_R3(Page): @staticmethod def before_next_page(player: Player, timeout_happened): if player.count_R3_big > 2: player.payoff_R3_big = 4 else: player.payoff_R3_big = 0 if player.count_R3_small > 2: player.payoff_R3_small = 1 else: player.payoff_R3_small = 0 if player.TaskChoice_R3 == 1: player.TaskChoice_small += 1 else: player.TaskChoice_big += 1 class Task_Assignment_R4(Page): form_model = 'player' form_fields = ['TaskChoice_R4'] class Task1_R4(Page): form_model = 'player' timer_text = C.TIMER_TEXT timeout_seconds = C.Game_Time @staticmethod def vars_for_template(player): import time player.time_R4_begin = int(time.time()) @staticmethod def live_method(player, data): # If the small grid is chosen if player.TaskChoice_R4 == 1 and 'foundPairs' in data: player.count_R4_small = data['foundPairs'] if player.TaskChoice_R4 == 1 and 'success_practice_small' in data: player.success_R4_small = data['success_R4_small'] # If the big grid is chosen if player.TaskChoice_R4 == 2 and 'foundPairs' in data: player.count_R4_big = data['foundPairs'] if player.TaskChoice_R4 == 2 and 'success_practice_big' in data: player.success_R4_big = data['success_R4_big'] @staticmethod def before_next_page(player: Player, timeout_happened): import time player.time_R4_end = int(time.time()) player.time_R4 = player.time_R4_end - player.time_R4_begin class Result_R4(Page): @staticmethod def before_next_page(player: Player, timeout_happened): if player.count_R4_big > 2: player.payoff_R4_big = 4 else: player.payoff_R4_big = 0 if player.count_R4_small > 2: player.payoff_R4_small = 1 else: player.payoff_R4_small = 0 if player.TaskChoice_R4 == 1: player.TaskChoice_small += 1 else: player.TaskChoice_big += 1 class Task_Assignment_R5(Page): form_model = 'player' form_fields = ['TaskChoice_R5'] class Task1_R5(Page): form_model = 'player' timer_text = C.TIMER_TEXT timeout_seconds = C.Game_Time @staticmethod def vars_for_template(player): import time player.time_R5_begin = int(time.time()) @staticmethod def live_method(player, data): # If the small grid is chosen if player.TaskChoice_R5 == 1 and 'foundPairs' in data: player.count_R5_small = data['foundPairs'] if player.TaskChoice_R5 == 1 and 'success_practice_small' in data: player.success_R5_small = data['success_R5_small'] # If the big grid is chosen if player.TaskChoice_R5 == 2 and 'foundPairs' in data: player.count_R5_big = data['foundPairs'] if player.TaskChoice_R5 == 2 and 'success_practice_big' in data: player.success_R5_big = data['success_R5_big'] @staticmethod def before_next_page(player: Player, timeout_happened): import time player.time_R5_end = int(time.time()) player.time_R5 = player.time_R5_end - player.time_R5_begin class Result_R5(Page): @staticmethod def before_next_page(player: Player, timeout_happened): if player.count_R5_big > 2: player.payoff_R5_big = 4 else: player.payoff_R5_big = 0 if player.count_R5_small > 2: player.payoff_R5_small = 1 else: player.payoff_R5_small = 0 if player.TaskChoice_R5 == 1: player.TaskChoice_small += 1 else: player.TaskChoice_big += 1 class Task_Assignment_R6(Page): form_model = 'player' form_fields = ['TaskChoice_R6'] class Task1_R6(Page): form_model = 'player' timer_text = C.TIMER_TEXT timeout_seconds = C.Game_Time @staticmethod def vars_for_template(player): import time player.time_R6_begin = int(time.time()) @staticmethod def live_method(player, data): # If the small grid is chosen if player.TaskChoice_R6 == 1 and 'foundPairs' in data: player.count_R6_small = data['foundPairs'] if player.TaskChoice_R6 == 1 and 'success_practice_small' in data: player.success_R6_small = data['success_R6_small'] # If the big grid is chosen if player.TaskChoice_R6 == 2 and 'foundPairs' in data: player.count_R6_big = data['foundPairs'] if player.TaskChoice_R6 == 2 and 'success_practice_big' in data: player.success_R6_big = data['success_R6_big'] @staticmethod def before_next_page(player: Player, timeout_happened): import time player.time_R6_end = int(time.time()) player.time_R6 = player.time_R6_end - player.time_R6_begin class Result_R6(Page): @staticmethod def before_next_page(player: Player, timeout_happened): if player.count_R6_big > 2: player.payoff_R6_big = 4 else: player.payoff_R6_big = 0 if player.count_R6_small > 2: player.payoff_R6_small = 1 else: player.payoff_R6_small = 0 if player.TaskChoice_R6 == 1: player.TaskChoice_small += 1 else: player.TaskChoice_big += 1 class Task_Assignment_R7(Page): form_model = 'player' form_fields = ['TaskChoice_R7'] class Task1_R7(Page): form_model = 'player' timer_text = C.TIMER_TEXT timeout_seconds = C.Game_Time @staticmethod def vars_for_template(player): import time player.time_R7_begin = int(time.time()) @staticmethod def live_method(player, data): # If the small grid is chosen if player.TaskChoice_R7 == 1 and 'foundPairs' in data: player.count_R7_small = data['foundPairs'] if player.TaskChoice_R7 == 1 and 'success_practice_small' in data: player.success_R7_small = data['success_R7_small'] # If the big grid is chosen if player.TaskChoice_R7 == 2 and 'foundPairs' in data: player.count_R7_big = data['foundPairs'] if player.TaskChoice_R7 == 2 and 'success_practice_big' in data: player.success_R7_big = data['success_R7_big'] @staticmethod def before_next_page(player: Player, timeout_happened): import time player.time_R7_end = int(time.time()) player.time_R7 = player.time_R7_end - player.time_R7_begin class Result_R7(Page): @staticmethod def before_next_page(player: Player, timeout_happened): if player.count_R7_big > 2: player.payoff_R7_big = 4 else: player.payoff_R7_big = 0 if player.count_R7_small > 2: player.payoff_R7_small = 1 else: player.payoff_R7_small = 0 if player.TaskChoice_R7 == 1: player.TaskChoice_small += 1 else: player.TaskChoice_big += 1 class Task_Assignment_R8(Page): form_model = 'player' form_fields = ['TaskChoice_R8'] class Task1_R8(Page): form_model = 'player' timer_text = C.TIMER_TEXT timeout_seconds = C.Game_Time @staticmethod def vars_for_template(player): import time player.time_R8_begin = int(time.time()) @staticmethod def live_method(player, data): # If the small grid is chosen if player.TaskChoice_R8 == 1 and 'foundPairs' in data: player.count_R8_small = data['foundPairs'] if player.TaskChoice_R8 == 1 and 'success_practice_small' in data: player.success_R8_small = data['success_R8_small'] # If the big grid is chosen if player.TaskChoice_R8 == 2 and 'foundPairs' in data: player.count_R8_big = data['foundPairs'] if player.TaskChoice_R8 == 2 and 'success_practice_big' in data: player.success_R8_big = data['success_R8_big'] @staticmethod def before_next_page(player: Player, timeout_happened): import time player.time_R8_end = int(time.time()) player.time_R8 = player.time_R8_end - player.time_R8_begin class Result_R8(Page): @staticmethod def before_next_page(player: Player, timeout_happened): if player.count_R8_big > 2: player.payoff_R8_big = 4 else: player.payoff_R8_big = 0 if player.count_R8_small > 2: player.payoff_R8_small = 1 else: player.payoff_R8_small = 0 if player.TaskChoice_R8 == 1: player.TaskChoice_small += 1 else: player.TaskChoice_big += 1 class Task_Assignment_R9(Page): form_model = 'player' form_fields = ['TaskChoice_R9'] class Task1_R9(Page): form_model = 'player' timer_text = C.TIMER_TEXT timeout_seconds = C.Game_Time @staticmethod def vars_for_template(player): import time player.time_R9_begin = int(time.time()) @staticmethod def live_method(player, data): # If the small grid is chosen if player.TaskChoice_R9 == 1 and 'foundPairs' in data: player.count_R9_small = data['foundPairs'] if player.TaskChoice_R9 == 1 and 'success_practice_small' in data: player.success_R9_small = data['success_R9_small'] # If the big grid is chosen if player.TaskChoice_R9 == 2 and 'foundPairs' in data: player.count_R9_big = data['foundPairs'] if player.TaskChoice_R9 == 2 and 'success_practice_big' in data: player.success_R9_big = data['success_R9_big'] @staticmethod def before_next_page(player: Player, timeout_happened): import time player.time_R9_end = int(time.time()) player.time_R9 = player.time_R9_end - player.time_R9_begin class Result_R9(Page): @staticmethod def before_next_page(player: Player, timeout_happened): if player.count_R9_big > 2: player.payoff_R9_big = 4 else: player.payoff_R9_big = 0 if player.count_R9_small > 2: player.payoff_R9_small = 1 else: player.payoff_R9_small = 0 if player.TaskChoice_R9 == 1: player.TaskChoice_small += 1 else: player.TaskChoice_big += 1 class Task_Assignment_R10(Page): form_model = 'player' form_fields = ['TaskChoice_R10'] class Task1_R10(Page): form_model = 'player' timer_text = C.TIMER_TEXT timeout_seconds = C.Game_Time @staticmethod def vars_for_template(player): import time player.time_R10_begin = int(time.time()) @staticmethod def live_method(player, data): # If the small grid is chosen if player.TaskChoice_R10 == 1 and 'foundPairs' in data: player.count_R10_small = data['foundPairs'] if player.TaskChoice_R10 == 1 and 'success_practice_small' in data: player.success_R10_small = data['success_R10_small'] # If the big grid is chosen if player.TaskChoice_R10 == 2 and 'foundPairs' in data: player.count_R10_big = data['foundPairs'] if player.TaskChoice_R10 == 2 and 'success_practice_big' in data: player.success_R10_big = data['success_R10_big'] @staticmethod def before_next_page(player: Player, timeout_happened): import time player.time_R10_end = int(time.time()) player.time_R10 = player.time_R10_end - player.time_R10_begin class Result_R10(Page): @staticmethod def before_next_page(player: Player, timeout_happened): if player.count_R10_big > 2: player.payoff_R10_big = 4 else: player.payoff_R10_big = 0 if player.count_R10_small > 2: player.payoff_R10_small = 1 else: player.payoff_R10_small = 0 if player.TaskChoice_R10 == 1: player.TaskChoice_small += 1 else: player.TaskChoice_big += 1 # Total payoff for task 1 player.payoff_task1 = player.payoff_R1_big + player.payoff_R2_small + player.payoff_R2_big + player.payoff_R3_small \ + player.payoff_R3_big + player.payoff_R4_small + player.payoff_R4_big + player.payoff_R5_small \ + player.payoff_R5_big + player.payoff_R6_small + player.payoff_R6_big + player.payoff_R7_small \ + player.payoff_R7_big + player.payoff_R8_small + player.payoff_R8_big + player.payoff_R9_small \ + player.payoff_R9_big + player.payoff_R10_small + player.payoff_R10_big class Task1_Summary(Page): pass class Instruction_Task2(Page): pass class Bomb(Page): form_model = 'player' form_fields = ['bomb', 'boxes_collected', 'bomb_row', 'bomb_col'] @staticmethod def js_vars(player: Player): participant = player.participant reset = participant.vars.pop('reset', False) if C.DYNAMIC: show_input = False else: show_input = not C.DEVILS_GAME return dict( reset=reset, show_input=show_input, NUM_ROWS=C.NUM_ROWS, NUM_COLS=C.NUM_COLS, BOX_HEIGHT=C.BOX_HEIGHT, BOX_WIDTH=C.BOX_WIDTH, FEEDBACK=C.FEEDBACK, RESULTS=C.RESULTS, DYNAMIC=C.DYNAMIC, TIME_INTERVAL=C.TIME_INTERVAL, RANDOM=C.RANDOM, UNDOABLE=C.UNDOABLE, ) @staticmethod def before_next_page(player: Player, timeout_happened): player.participant.vars['reset'] = True set_payoff(player) class Task2_Summary (Page): @staticmethod def vars_for_template(player: Player): return dict( box_value=C.BOX_VALUE, boxes_collected=player.boxes_collected, bomb=player.bomb, bomb_row=player.bomb_row, bomb_col=player.bomb_col, result=player.result, ) class Survey (Page): form_model = 'player' form_fields = ['Gender', 'Grade', 'Class', 'Student_ID', 'School'] @staticmethod def before_next_page(player: Player, timeout_happened): player.total_payoff = player.payoff_task1 + player.result + 5 class Final (Page): @staticmethod def vars_for_template(player: Player): return dict( payoff_task1=player.payoff_task1, payoff_task2=player.result, total_payoff=player.total_payoff ) page_sequence = [General_Instructions, Instruction_Task1, Practice, Practice_Small, Practice_Big, Task1, Task1_R1, Result_R1, Task_Assignment_R2, Task1_R2, Result_R2, Task_Assignment_R3, Task1_R3, Result_R3, Task_Assignment_R4, Task1_R4, Result_R4, Task_Assignment_R5, Task1_R5, Result_R5, Task_Assignment_R6, Task1_R6, Result_R6, Task_Assignment_R7, Task1_R7, Result_R7, Task_Assignment_R8, Task1_R8, Result_R8, Task_Assignment_R9, Task1_R9, Result_R9, Task_Assignment_R10, Task1_R10, Result_R10, Task1_Summary, Instruction_Task2, Bomb, Task2_Summary, Survey, Final]