from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) import jellyfish import numpy author = 'Your name here' doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'Greek_Task' players_per_group = None num_rounds = 300 class Subsession(BaseSubsession): def before_session_starts(self): for p in self.get_players(): p.tries = 1 transcription_data = p.transcription() p.tran_key = transcription_data['answer_key'] p.tran_path = transcription_data['file'] class Group(BaseGroup): pass class Player(BasePlayer): tries = models.PositiveIntegerField() tran_id = models.PositiveIntegerField() tran_key = models.CharField() tran_path = models.CharField() tran_submitted_answer = models.CharField() is_correct = models.BooleanField(initial=0) is_correct_main = models.BooleanField(initial=0) num_changes_req = models.PositiveIntegerField() # def getTasksChosen(self): # return self.participant.vars['tasks_chosen'] # def getWageRealized(self): # return self.participant.vars['wage_final'] def transcription(self): return self.participant.vars['main_transcriptions'][self.round_number - 1] def check_correct(self): self.is_correct=jellyfish.levenshtein_distance(self.tran_key,self.tran_submitted_answer)<7 def check_correct_main(self): self.is_correct_main = jellyfish.levenshtein_distance(self.tran_key, self.tran_submitted_answer) < 7 year = models.PositiveIntegerField( choices=[ [1, 'First'], [2, 'Second'], [3, 'Third'], [4, 'Fourth'], [5, 'Other'], ], widget=widgets.RadioSelectHorizontal(), verbose_name="") major = models.CharField() gender = models.PositiveIntegerField( choices=[ [1, 'Male'], [2, 'Female'], [3, 'Decline to Answer'], ], widget=widgets.RadioSelectHorizontal(), verbose_name="")