from otree.api import * import math import pandas as pd import itertools import numpy as np class C(BaseConstants): NAME_IN_URL = 'results' PLAYERS_PER_GROUP = 4 NUM_ROUNDS = 1 RESULTS_TEMPLATE = 'cpr_results/templates/results.html' SURVEY_TEMPLATE = 'cpr_results/templates/survey.html' ELICITATION_TEMPLATE = 'cpr_results/templates/elicitation.html' ECUS_PER_POUND = 50 POUNDS_PER_ECU = 1 / ECUS_PER_POUND PARTICIPATION_FEE = 3 #SVO_VALUES = pd.read_csv("cpr_defaults/svo_values.csv") class Subsession(BaseSubsession): pass def creating_session(subsession): pass class Group(BaseGroup): pass class Player(BasePlayer): extraction = models.IntegerField(initial=0) motivation = models.LongStringField(label="In the last task, what was your reasoning behind your desired extraction?", initial = "") feedback = models.LongStringField( label="Are there any comments or feedback you would like to provide for this experiment?", initial = "") knowledge_gametheory = models.LongStringField( label="Were you familiar with these types of experiment?", initial="") concepts_gametheory = models.LongStringField( label = "Did you know about concepts such as 'game theory', 'behavioural experiments' or 'common pool resource dilemmas'?", initial = "" ) internal_id = models.IntegerField() chosen_task = models.IntegerField() payoff_pounds = models.CurrencyField() total_payoff_exp = models.CurrencyField() # FUNCTIONS # PAGES class Results(Page): @staticmethod def vars_for_template(player): player.payoff = 0 player.payoff_pounds = 0 player.participant.payoff_task3 = np.round(player.participant.payoff_task3, 2) if player.participant.payoff_task3 < 0: player.participant.payoff_task3 = 0 player.payoff = player.participant.payoff_task1 + player.participant.payoff_task2 + player.participant.payoff_task3 player.payoff_pounds = player.payoff * C.POUNDS_PER_ECU player.total_payoff_exp = player.payoff_pounds + C.PARTICIPATION_FEE class Survey(Page): form_model = 'player' form_fields = ['motivation', 'feedback', 'knowledge_gametheory', "concepts_gametheory"] @staticmethod def live_method(player, data): player.motivation = data["motivation"] player.feedback = data["feedback"] @staticmethod def before_next_page(player, timeout_happened): player.participant.finished_participant = True player.participant.reason_finished = "You successfully completed the three tasks. You will be paid for your time and the extra bonus. Total = £%.2f" % player.total_payoff_exp page_sequence = [Results, Survey] #page_sequence = [Survey]