from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) import itertools, random import json author = 'Your name here' doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'number_task' players_per_group = None num_rounds = 1 # block randomization of pages class Subsession(BaseSubsession): def creating_session(self): from .pages import no_page_sequence aaa = [i.__name__.split('_') for i in no_page_sequence] page_blocks = [list(group) for key, group in itertools.groupby(aaa, key=lambda x: x[0])] for p in self.get_players(): pb=page_blocks.copy() random.shuffle(pb) level1 = list(itertools.chain.from_iterable(pb)) level2 = ['_'.join(i) for i in level1] p.page_sequence = json.dumps(level2) class Group(BaseGroup): pass class Player(BasePlayer): dec_1 = models.IntegerField( label="Einfach", min=0, max=7, ) dec_2 = models.IntegerField( label="Mittel", min=0, max=7, ) dec_3 = models.IntegerField( label="Schwer", min=0, max=7, ) row_1 = models.IntegerField( #label="2 - 5 - 8 - 11 - 14 - 17 - 20 -? ", min=0, max=500,label=False, ) row_2 = models.IntegerField( #label="16 - 14 - 12 - 10 - 8 - 6 - 4 -? ", min=0, max=500,label=False, ) row_3 = models.IntegerField( #label="13 – 15 – 18 – 14 – 24 – 25 – 5 –?", min=0, max=500, label=False ) row_4 = models.IntegerField( #label="15 – 6 – 18 – 8 – 30 – 29 – 9 –?", min=0, max=500,label=False ) row_5 = models.IntegerField( #label="8 – 11 – 14 – 23 – 30 – 43 – 56 –?", min=0, max=500,label=False ) row_6 = models.IntegerField( #label="15 – 6 – 18 – 8 – 30 – 29 – 9 –?", min=0, max=500,label=False ) row_7 = models.IntegerField( #label="9 – 6 – 18 – 19 – 7 – 5 – 10 –?", min=0, max=500,label=False ) page_sequence = models.StringField()