from otree.api import * from MGPGG_utils.common_functions import make_comprehension_question import time doc = """ Instructions and Comprehension Questions for the Strategy Method """ class C(BaseConstants): NAME_IN_URL = 'StrategyMethodInstrucsCompQs' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 ENDOWMENT = cu(20) class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): # Create Comprehension Questions comprehension_question_one_part_one = make_comprehension_question("What is you total income?") comprehension_question_one_part_two = make_comprehension_question("What is the total income of another member" " of your group?") comprehension_question_two_part_one = make_comprehension_question("What is you total income?") comprehension_question_two_part_two = make_comprehension_question("What is the total income of another member" " of your group?") comprehension_question_three_part_one = make_comprehension_question("What is your total income if you invest 0" " points to the Group's Joint Account?") comprehension_question_three_part_two = make_comprehension_question("What is your total income if you instead" " invest 4 points to the Group's Joint " "Account?") comprehension_question_three_part_three = make_comprehension_question("What is your total income if you instead" " invest 10 points to the Group's Joint " "Account?") comprehension_question_four_part_one = make_comprehension_question("Your group members invest a combined 0 points" " to the Group's Joint Account. What is your " "total income?") comprehension_question_four_part_two = make_comprehension_question("Your group members invest a combined 10 points" " to the Group's Joint Account. What is your " "total income?") comprehension_question_four_part_three = make_comprehension_question("Your group members invest a combined 30" " points to the Group's Joint Account. What is " "your total income?") # Time to answer questions time_to_answer = models.IntegerField(initial=360) # 6 minutes # Time Tracking start_time = models.FloatField(initial=0) time_spent_instrucs = models.FloatField(initial=0) time_spent_q_one = models.FloatField(initial=0) time_spent_q_two = models.FloatField(initial=0) time_spent_q_three = models.FloatField(initial=0) time_spent_q_four = models.FloatField(initial=0) # Error Tracking num_errors_q_one_a = models.IntegerField(initial=0) num_errors_q_one_b = models.IntegerField(initial=0) num_errors_q_two_a = models.IntegerField(initial=0) num_errors_q_two_b = models.IntegerField(initial=0) num_errors_q_three_a = models.IntegerField(initial=0) num_errors_q_three_b = models.IntegerField(initial=0) num_errors_q_three_c = models.IntegerField(initial=0) num_errors_q_four_a = models.IntegerField(initial=0) num_errors_q_four_b = models.IntegerField(initial=0) num_errors_q_four_c = models.IntegerField(initial=0) # PAGES class Instructions(Page): @staticmethod def is_displayed(player: Player): player.start_time = time.time() return True @staticmethod def before_next_page(player: Player, timeout_happened): player.time_to_answer += int(time.time()) # Save instructions time player.time_spent_instrucs = time.time() - player.start_time # reset start_time to time next page player.start_time = time.time() if player.time_spent_q_one is None: player.time_spent_q_one = 0 class QuestionOne(Page): form_model = 'player' form_fields = ['comprehension_question_one_part_one', 'comprehension_question_one_part_two'] timer_text = 'Time left to complete the quiz:' @staticmethod def get_timeout_seconds(player: Player): return player.time_to_answer - time.time() @staticmethod def error_message(player: Player, values): if values['comprehension_question_one_part_one'] != 20: end_time = time.time() elapsed_time = end_time - player.start_time player.time_spent_q_one += elapsed_time # Increment total time spent on this page player.start_time = time.time() # Reset the start time for the next iteration player.num_errors_q_one_a += 1 return 'Reconsider your answer to question one part A: You invest 0 points to the Group Account (Your other' \ ' Group members do the same). Therefore, your Individual Share is 0 points. With this, you invest all' \ ' 20 of your points are in your Personal Account. Sum these two together for your Total Earnings.' if values['comprehension_question_one_part_two'] != 20: end_time = time.time() elapsed_time = end_time - player.start_time player.time_spent_q_one += elapsed_time # Increment total time spent on this page player.start_time = time.time() # Reset the start time for the next iteration player.num_errors_q_one_b += 1 return 'Reconsider your answer to question one part B: The other members of your group made the same investment' \ ' choice that did, and their earnings are calculated in the same way that yours are.' @staticmethod def before_next_page(player: Player, timeout_happened): end_time = time.time() elapsed_time = end_time - player.start_time player.time_spent_q_one += elapsed_time # Increment total time spent on this page # Reset timers for Q_2 player.start_time = time.time() if player.time_spent_q_two is None: player.time_spent_q_two = 0 class QuestionTwo(Page): form_model = 'player' form_fields = ['comprehension_question_two_part_one', 'comprehension_question_two_part_two'] timer_text = 'Time left to complete the quiz:' @staticmethod def get_timeout_seconds(player: Player): return player.time_to_answer - time.time() @staticmethod def error_message(player: Player, values): if values['comprehension_question_two_part_one'] != 40: end_time = time.time() elapsed_time = end_time - player.start_time player.time_spent_q_two += elapsed_time # Increment total time spent on this page player.start_time = time.time() # Reset the start time for the next iteration player.num_errors_q_two_a += 1 return 'Reconsider your answer to question two part A: With all group members investing 20 points to the' \ ' Group Account, this totals 80 points. Then to calculate the Individual Share, multiply this total' \ ' by 0.5. Since all members, including you, are investing all of the points they receive (20 points),' \ ' they have 0 points in their Personal Account. Sum these two together for your Total Earnings. ' if values['comprehension_question_two_part_two'] != 40: end_time = time.time() elapsed_time = end_time - player.start_time player.time_spent_q_two += elapsed_time # Increment total time spent on this page player.start_time = time.time() # Reset the start time for the next iteration player.num_errors_q_two_b += 1 return 'Reconsider your answer to question two part B: Your group members Individual Shares, Personal Accounts,' \ ' and Total Earnings involve the same formula as yours.' @staticmethod def before_next_page(player: Player, timeout_happened): end_time = time.time() elapsed_time = end_time - player.start_time player.time_spent_q_two += elapsed_time # Increment total time spent on this page # Reset Timers for Q3 player.start_time = time.time() if player.time_spent_q_three is None: player.time_spent_q_three = 0 class QuestionThree(Page): form_model = 'player' form_fields = ['comprehension_question_three_part_one', 'comprehension_question_three_part_two', 'comprehension_question_three_part_three'] timer_text = 'Time left to complete the quiz:' @staticmethod def get_timeout_seconds(player: Player): return player.time_to_answer - time.time() @staticmethod def error_message(player: Player, values): if values['comprehension_question_three_part_one'] != 33: end_time = time.time() elapsed_time = end_time - player.start_time player.time_spent_q_three += elapsed_time # Increment total time spent on this page player.start_time = time.time() # Reset the start time for the next iteration player.num_errors_q_three_a += 1 return 'Reconsider your answer to question three part A: If you invest 0 to the Group Account, then total' \ ' investment to the Group Account is 26 points. Your Individual Share is 26 times 0.5. By investing 0' \ ' points to the Group Account, your Personal Account is 20 points (20 - 0 = 20). Sum your Individual' \ ' Share, and your Personal Account together for your Total Income.' if values['comprehension_question_three_part_two'] != 31: end_time = time.time() elapsed_time = end_time - player.start_time player.time_spent_q_three += elapsed_time # Increment total time spent on this page player.start_time = time.time() # Reset the start time for the next iteration player.num_errors_q_three_b += 1 return 'Reconsider yor answer to question three part B: If you invest 4 points to the Group Account, then ' \ 'total investment to the Group Account is 30 points. Your Individual Share is 30 times 0.5. By ' \ 'investing 4 points to the Group Account, your Personal Account is 16 points (20 - 4 = 16). Sum ' \ 'your Individual Share, and your Personal Account together for your Total Income.' if values['comprehension_question_three_part_three'] != 28: end_time = time.time() elapsed_time = end_time - player.start_time player.time_spent_q_three += elapsed_time # Increment total time spent on this page player.start_time = time.time() # Reset the start time for the next iteration player.num_errors_q_three_c += 1 return 'Reconsider your answer to question three part C: If you invest 10 points to the Group Account, then ' \ 'total investment to the Group Account is 36 points. Your Individual Share is 36 times 0.5. By ' \ 'investing 10 points to the Group Account, your Personal Account is 10 points (20 - 10 = 10). Sum ' \ 'your Individual Share, and your Personal Account together for your Total Income.' @staticmethod def before_next_page(player: Player, timeout_happened): end_time = time.time() elapsed_time = end_time - player.start_time player.time_spent_q_three += elapsed_time # Increment total time spent on this page # Reset Timers for Q4 player.start_time = time.time() if player.time_spent_q_four is None: player.time_spent_q_four = 0 class QuestionFour(Page): form_model = 'player' form_fields = ['comprehension_question_four_part_one', 'comprehension_question_four_part_two', 'comprehension_question_four_part_three'] timer_text = 'Time left to complete the quiz:' @staticmethod def get_timeout_seconds(player: Player): return player.time_to_answer - time.time() @staticmethod def error_message(player: Player, values): if values['comprehension_question_four_part_one'] != 17: end_time = time.time() elapsed_time = end_time - player.start_time player.time_spent_q_four += elapsed_time # Increment total time spent on this page player.start_time = time.time() # Reset the start time for the next iteration player.num_errors_q_four_a += 1 return 'Reconsider your answer to question four part A: With the other members of your group investing a ' \ 'combined 0 points to the Group Account, total investment to the Group Account is 6 points. ' \ 'Therefore, your Individual Share is 6 x 0.5. With your investment of 6 points, your Personal Account' \ ' is 14 points (20 - 6 = 14). To find your Total Income, sum your Individual Share and ' \ 'your Personal Account.' if values['comprehension_question_four_part_two'] != 22: end_time = time.time() elapsed_time = end_time - player.start_time player.time_spent_q_four += elapsed_time # Increment total time spent on this page player.start_time = time.time() # Reset the start time for the next iteration player.num_errors_q_four_b += 1 return 'Reconsider your answer to question four part B: With the other members of your group investing a ' \ 'combined 10 points to the Group Account, total investment to the Group Account is 16 points. ' \ 'Therefore, your Individual Share is 16 x 0.5. With your investment of 6 points, your Personal Account ' \ 'is 14 points (20 - 6 = 14). To find your Total Income, sum your Individual Share and your Personal' \ ' Account.' if values['comprehension_question_four_part_three'] != 32: end_time = time.time() elapsed_time = end_time - player.start_time player.time_spent_q_four += elapsed_time # Increment total time spent on this page player.start_time = time.time() # Reset the start time for the next iteration player.num_errors_q_four_c += 1 return 'Reconsider your answer to question four part C: With the other members of your group investing a ' \ 'combined 30 points to the Group Account, total investment to the Group Account is 36 points. ' \ 'Therefore, your Individual Share is 36 x 0.5. With your investment of 6 points, your Personal Account ' \ 'is 14 points (20 - 6 = 14). To find your Total Income, sum your Individual Share and your Personal' \ ' Account.' @staticmethod def before_next_page(player: Player, timeout_happened): end_time = time.time() elapsed_time = end_time - player.start_time player.time_spent_q_four += elapsed_time # Increment total time spent on this page class ResultsWaitPage(WaitPage): pass class Results(Page): pass page_sequence = [Instructions, QuestionOne, QuestionTwo, QuestionThree, QuestionFour, Results, ResultsWaitPage]