from otree.api import Currency as c, currency_range from . import models from ._builtin import Page, WaitPage from .models import Constants import time # ******************************************************************************************************************** # # *** PAGE INSTRUCTIONS *** # # ******************************************************************************************************************** # class Instructions(Page): # only display instruction in round 1 # ---------------------------------------------------------------------------------------------------------------- def is_displayed(self): return self.subsession.round_number == 1 def vars_for_template(self): return { 'audio_path': 'oyun6.mp3', } # ******************************************************************************************************************** # # *** PAGE PRACTICE *** # # ******************************************************************************************************************** # class Practice(Page): # only display instruction in round 1 # ---------------------------------------------------------------------------------------------------------------- def is_displayed(self): return self.subsession.round_number == 1 def before_next_page(self): # user has 5 minutes to complete as many pages as possible self.participant.vars['expiry_timestamp'] = time.time() + Constants.minutes_given*60 # ******************************************************************************************************************** # # *** PAGE DECISION *** # # ******************************************************************************************************************** # class Decision(Page): # form model and form fields # ---------------------------------------------------------------------------------------------------------------- form_model = 'player' form_fields = ['choice'] timer_text = 'Testin bitmesine kalan süre' def get_timeout_seconds(self): return self.participant.vars['expiry_timestamp'] - time.time() # def is_displayed(self): return self.get_timeout_seconds() > 2 # variables for template # ---------------------------------------------------------------------------------------------------------------- def vars_for_template(self): # specify info for progress bar # total = len(Constants.images) // old total = Constants.num_rounds page = self.subsession.round_number progress = page / total * 100 item_set = list( zip( Constants.choices[page - 1], Constants.synonyms[page - 1], Constants.examples[page - 1] ) ) # return variables return { 'image_path': 'egt/img/{}.png'.format(self.round_number), 'page': page, 'total': total, 'progress': progress, 'set': item_set } # 'img': Constants.images[page - 1], # verify whether choice has been correct # ---------------------------------------------------------------------------------------------------------------- def before_next_page(self): self.player.verify_if_correct() class End(Page): def is_displayed(self): return self.subsession.round_number == 20 def before_next_page(self): self.player.set_payoffs() # ******************************************************************************************************************** # # *** PAGE SEQUENCE *** # # ******************************************************************************************************************** # page_sequence = [ Instructions, Practice, Decision, End ]