from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) import pandas as pd import random author = 'Your name here' doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'frenchlearning' players_per_group = None df = pd.read_excel("_static/global/French Numbers.xlsx") num_rounds = df.shape[0] class Subsession(BaseSubsession): # def creating_session(self): # idxes = random.sample(range(0, Constants.num_rounds), Constants.num_rounds) # random_lst = [] # for idx in idxes: # random_lst.append(Constants.df.iloc[idx, 1]) # # for p in self.get_players(): # p.participant.vars["random_lst"] = random_lst pass class Group(BaseGroup): pass class Player(BasePlayer): time = models.IntegerField( min=1, max=30 ) number = models.IntegerField( min=1, max=100, doc="You have to choose between 1 - 100" ) word = models.StringField() answer = models.StringField( blank=False, doc="You got it wrong!" ) correct = models.BooleanField() def choose_numbers(self): idxes = random.sample(range(0, self.number), self.number) random_lst = [] for idx in idxes: random_lst.append(Constants.df.iloc[idx, 1]) self.participant.vars["random_lst"] = random_lst