from otree.api import * c = cu doc = '' class C(BaseConstants): NAME_IN_URL = 'Intro' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 LANGUAGE = 'PL' DALEJ_TEMPLATE = 'Intro/dalej.html' class Subsession(BaseSubsession): pass def creating_session(subsession: Subsession): session = subsession.session import random if subsession.round_number == 1: paying_round = random.randint(1, 8) session.vars['paying_round'] = paying_round labels = ['F1Y1', 'F1G1', 'F2Y2', 'F2G2'] for player, label in zip(subsession.get_players(), labels): player.participant.label = label Subsession.creating_session = creating_session class Group(BaseGroup): pass class Player(BasePlayer): age = models.IntegerField(label='Proszę podać swój wiek', max=99, min=0) gender = models.IntegerField(choices=[[0, 'mężczyzna'], [1, 'kobieta']], label='Płeć', widget=widgets.RadioSelectHorizontal) def custom_export(players): yield ['participant_code', 'id_in_group', 'gender'] for p in players: pp = p.participant yield [pp.code, p.id_in_group, pp.gender] class InitialQuestions(Page): form_model = 'player' form_fields = ['age', 'gender'] class Instruction(Page): form_model = 'player' @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant participant.vars["gender"] = player.gender class Instructions2(Page): form_model = 'player' page_sequence = [InitialQuestions, Instruction, Instructions2]