from otree.api import * import os import pandas as pd def make_field(label): return models.StringField( label=label, widget=widgets.RadioSelect, ) class C(BaseConstants): NAME_IN_URL = 'survey' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 txtFileName = '标签分类_20220518.xlsx' answer = [[1, '附带效益'], [2, '全球问题'], [3, '科学问题'], [4, '政治问题'], [5, '道德问题'], [6, '经济问题'], [7, '能源问题']] # current_working_path = os.getcwd() # appFloderName = 'Label_Survey' # txtPathName = "%s/%s/%s"%(current_working_path,appFloderName,txtFileName) # with open(txtPathName, 'r',encoding = 'unicode_escape') as file_object: # text=[] # for line in file_object.readlines(): # text.append(line.strip()) # fpath = r"C:\Users\LJW\Desktop\标签分类_20220518.xlsx" # df_label = pd.read_excel(fpath) class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): # age = models.IntegerField(label='What is your age?', min=13, max=125) c=C() # df = c.df_label answer=c.answer Label = models.StringField( # choices=[['Male', 'Male'], ['Female', 'Female']], choices=answer, label='请给出数据的分类?', widget=widgets.RadioSelect, ) ID = make_field('1') Comment = make_field('西北大学榆林碳中和学院揭牌 - 榆林 - 陕西每日传媒网 O网页链接 ?') WeiBo_ID = make_field('4636438715696340') Method = make_field('最大信息熵') # FUNCTIONS # PAGES class MyPage(Page): form_model = 'player' form_fields = ['ID','Comment','WeiBo_ID','Method','Label'] class Results(Page): form_model = 'player' page_sequence = [MyPage, Results]