from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) import pandas as pd import random from glob import glob from os import getcwd from os.path import join from os.path import expanduser, join # *** This # from glob import glob # from os.path import expanduser, join # Return everything under the user directory that contains a folder called wlp. # glob(join(expanduser('~'), '*', 'wlp')) # x = glob(join(getcwd(), '*', 'Codiert')) # path = x[0] # pic_names = os.listdir(path) # pic_names[:] = [x for x in pic_names if "jpg" not in x] author = 'Your name here' doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'Seminar' players_per_group = None num_rounds = 1 x = glob(join(getcwd(), '*', 'Codiert')) path = x[0] pic_names = os.listdir(path) pic_names[:] = [x for x in pic_names if "jpg" not in x] class Subsession(BaseSubsession): def creating_session(self): if self.round_number == 1: for player in self.get_players(): list_of_fotos = Constants.df.sample(n=3) player.photoid_1 = list_of_fotos.iloc[0,0] player.word_1 = list_of_fotos.iloc[0,1] player.photoid_2 = list_of_fotos.iloc[1,0] player.word_2 = list_of_fotos.iloc[1,1] player.photoid_2 = list_of_fotos.iloc[2, 0] player.word_2 = list_of_fotos.iloc[2, 1] class Group(BaseGroup): pass class Player(BasePlayer): photoid_1 = models.StringField() photoid_2 = models.StringField() photoid_3 = models.StringField() word_1 = models.StringField() word_2 = models.StringField() word_3 = models.StringField()