from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants import jellyfish class Main_Intro(Page): def is_displayed(self): return self.round_number==1 def vars_for_template(self): return { 'numTasks_todo': self.participant.vars['tasks_chosen'], 'wage_realized': self.participant.vars['wage_final'], 'show_up_fee': self.session.config['participation_fee'], 'total_earnings': self.participant.payoff_plus_participation_fee(), 'potential_wage_low': self.participant.vars['wage_potential_l'], 'potential_wage_high': self.participant.vars['wage_potential_h'], 'fixed_possible': self.participant.vars['fixed_chosen'], 'num_mandatory': self.session.config['mandatory_rounds'] } class MainTasks_Click(Page): form_model = 'player' form_fields = ['tran_submitted_answer'] def vars_for_template(self): player_in_all_rounds = self.player.in_all_rounds() return { 'image_path': 'transcription_pics/{}'.format(self.player.tran_path), 'player_in_all_rounds': player_in_all_rounds, 'number_correct': sum([p.is_correct_main for p in player_in_all_rounds]), 'target': self.participant.vars['tasks_chosen'], 'attempts': self.player.tries, 'correct_answer': self.player.tran_key, 'greek_task': self.player.transcription(), 'noise_timer_min': 5, 'noise_timer_max': 15, } def before_next_page(self): self.player.check_correct_main() def error_message(self, values): correct = jellyfish.levenshtein_distance(values['tran_submitted_answer'], self.player.tran_key)<7 if (self.player.tries < 3): if not correct: self.player.tries += 1 return "Incorrect, please try again." def is_displayed(self): player_in_all_rounds = self.player.in_all_rounds() bool1 = sum([p.is_correct_main for p in player_in_all_rounds]) < self.participant.vars['tasks_chosen'] return bool1 class ResultsWaitPage(WaitPage): def after_all_players_arrive(self): pass class Results(Page): form_model = 'player' form_fields = ['year', 'major', 'gender'] def is_displayed(self): player_in_all_rounds = self.player.in_all_rounds() bool2 = sum([p.is_correct_main for p in player_in_all_rounds]) == self.participant.vars['tasks_chosen'] return bool2 class Results2(Page): def is_displayed(self): player_in_all_rounds = self.player.in_all_rounds() bool3 = sum([p.is_correct_main for p in player_in_all_rounds]) == self.participant.vars['tasks_chosen'] return bool3 def vars_for_template(self): return { 'numTasks_todo': self.participant.vars['tasks_chosen'], 'wage_realized': self.participant.vars['wage_final'], 'show_up_fee': self.session.config['participation_fee'], 'total_earnings': self.participant.payoff_plus_participation_fee(), } class Goodbye_Page(Page): def is_displayed(self): player_in_all_rounds = self.player.in_all_rounds() bool4 = sum([p.is_correct_main for p in player_in_all_rounds]) == self.participant.vars['tasks_chosen'] return bool4 page_sequence = [ Main_Intro, MainTasks_Click, Results, Results2, Goodbye_Page ]