from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants from . import models import random from otreeutils.pages import UnderstandingQuestionsPage class ColorBlind(Page): def is_displayed(self): return self.subsession.round_number == 1 form_model = 'player' form_fields = ['color_blind_1', 'color_blind_2', 'color_blind_3'] def before_next_page(self): self.participant.vars["num_skips"]=0 if self.player.color_blind_1==Constants.color_blind1 and self.player.color_blind_2==Constants.color_blind2 and self.player.color_blind_3==Constants.color_blind3: self.player.can_see_color=True self.participant.vars["can_see_color"]=True else: self.player.can_see_color=False self.participant.vars["can_see_color"]=False class Instructions(Page): def is_displayed(self): self.participant.vars["quiz_fail"]=False return self.subsession.round_number == 1 and self.participant.vars["can_see_color"] == True and self.player.is_on_mobile!=True class Quiz(UnderstandingQuestionsPage): template_name = 'Colors/quiz.html' form_model = models.Player form_field_n_wrong_attempts = 'understanding_questions_wrong_attempts' #set_correct_answers = True def get_questions(self): questions = [ { 'question': 'What is your task during each period?', 'options': ["To determine which color is brighter","To determine which color is darker","To determine if the two colors are the same"], 'correct': "To determine if the two colors are the same" }, { 'question': 'I can spend as much time as I want during each period.', 'options': ["True","False"], 'correct': "False" }, { 'question': 'I can increase my bonus through my choices.', 'options': ["True","False"], 'correct': "True" } ] return questions def is_displayed(self): return not('skip_quiz' in self.session.config) and self.subsession.round_number==1 and self.participant.vars["can_see_color"] == True and self.player.is_on_mobile!=True def before_next_page(self): if self.player.understanding_questions_wrong_attempts==1: self.participant.vars["quiz_fail"]=True self.player.quiz_fail=True class quiz_correct(Page): def is_displayed(self): return self.subsession.round_number == 1 and self.participant.vars["can_see_color"] == True and self.player.is_on_mobile!=True and self.participant.vars["quiz_fail"]!=True class practice_done(Page): def is_displayed(self): return self.subsession.round_number == Constants.practice_periods +1 and self.participant.vars["can_see_color"] == True and self.player.is_on_mobile!=True and self.participant.vars["quiz_fail"]!=True and self.participant.vars["num_skips"]<=Constants.max_skips class CompareColors(Page): def is_displayed(self): return self.participant.vars["can_see_color"] == True and self.player.is_on_mobile!=True and self.participant.vars["num_skips"]Constants.practice_periods: total_incentivized=total_incentivized+p.supervisor_is_correct self.player.total_with_practice=total_with_practice self.player.total_incentivized=total_incentivized self.participant.payoff=total_incentivized*Constants.bonus_per_round else: self.participant.vars["Color"]=self.participant.vars["Colors"].pop() class timed_out(Page): def is_displayed(self): return self.player.player_did_not_choose == True class Kicked_out(Page): def is_displayed(self): return self.player.can_see_color == False or self.player.is_on_mobile==True or self.participant.vars["quiz_fail"]==True or self.participant.vars["num_skips"]>=Constants.max_skips def vars_for_template(self): return dict( skipped_too_much = (self.participant.vars["num_skips"]>Constants.max_skips), is_mobile = self.player.is_on_mobile, is_color_blind=(self.player.can_see_color==False), fail_quiz=(self.participant.vars["quiz_fail"]==True) ) class peq1(Page): form_model = 'player' form_fields = ['peq_reasonable_disagreement','peq_different_hour','peq_different_emotion'] def is_displayed(self): return self.subsession.round_number == Constants.num_rounds and self.participant.vars["can_see_color"] == True and self.player.is_on_mobile!=True and self.participant.vars["num_skips"]