from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants debug = True ''' class QuizQuestions(Page): form_model = 'player' def get_form_fields(self): if self.player.q1_answered == False: return ['question_one_response'] elif self.player.q1_answered == True and self.player.q2_answered == False: return ['question_two_response'] elif self.player.q3_answered == False: return ['question_three_response'] elif self.player.q4_answered == False: return ['question_four_response'] elif self.player.q5_answered == False: return ['question_five_response'] elif self.player.q6_answered == False: return ['question_six_response'] '''form_fields = ['question_one_response', 'question_two_response', 'question_three_response', 'question_four_response', 'question_five_response', 'question_six_response']''' def question_one_response_error_message(self, value): if value != True: self.player.q1_incorrect_attempts += 1 return 'Incorrect. The correct answer is a:' + '\nTrue' else: self.player.q1_answered = True def question_two_response_error_message(self, value): if value != 1: self.player.q2_incorrect_attempts += 1 return 'Incorrect. The correct answer is a:' + '\nThe lender offers a loan and a repayment rate, the borrower offers collateral, the lender accepts the loan agreement' else: self.player.q2_answered = True def question_three_response_error_message(self, value): if value != 1: self.player.q3_incorrect_attempts += 1 return 'Incorrect. The correct answer is a: 0-10' else: self.player.q3_answered = True def question_four_response_error_message(self, value): if value != 4: self.player.q4_incorrect_attempts += 1 return 'Incorrect. The correct answer is d: 3' else: self.player.q4_answered = True def question_five_response_error_message(self, value): if value != 2 and (Constants.treatment == 'treatment1' or Constants.treamtent == 'treatment2'): self.player.q5_incorrect_attempts += 1 return 'Incorrect. The correct answer is b: The lender' elif value != 2: self.player.q5_incorrect_attempts += 1 return 'Incorrect. The correct answer is a: A contractual algorithm' else: self.player.q5_answered = True def question_six_response_error_message(self, value): if value != 3: self.player.q6_incorrect_attempts += 1 return 'Incorrect. The correct answer is c:' + '\nThe lender can obtain some value from the collateral up to the value minus the collateral fee' else: self.player.q6_answered = True def before_next_page(self): if self.player.q1_incorrect_attempts < 1: self.player.num_correct += 1 self.player.quiz_earnings += 2 if self.player.q2_incorrect_attempts < 1: self.player.num_correct += 1 self.player.quiz_earnings += 2 if self.player.q3_incorrect_attempts < 1: self.player.num_correct += 1 self.player.quiz_earnings += 2 if self.player.q4_incorrect_attempts < 1: self.player.num_correct += 1 self.player.quiz_earnings += 2 if self.player.q5_incorrect_attempts < 1: self.player.num_correct += 1 self.player.quiz_earnings += 2 if self.player.q6_incorrect_attempts < 1: self.player.num_correct += 1 self.player.quiz_earnings += 2 class QuizResults(Page): def vars_for_template(self): return {'dollar_amount': self.player.quiz_earnings.to_real_world_currency(self.session) } def before_next_page(self): self.participant.payoff += c(self.player.quiz_earnings) class WaitForPlayer(WaitPage): """waitpages""" pass class ResultsWaitPage(WaitPage): def after_all_players_arrive(self): pass page_sequence = [ QuizQuestions, QuizResults, ResultsWaitPage ] '''