from otree.api import * import random import string # import csv doc = """ Your app description """ # Payoff rule # Idea: We select a random number between 0 and 10. If 0 is picked the first decision is taken and so on. Then, for the taken decision, the binarized scoring rule is applied. # this has to be repeated for the other beliefs as well ... ########################################################################################################### ################################## MODELS ################################ ########################################################################################################### class Constants(BaseConstants): name_in_url = 'transcription_practise' players_per_group = None num_rounds = 10 num_training_rounds = 10 # num rounds stage 1 num_letters = 6 # base_tasks = 50 numbers_list = [] for i in range(1, 27): numbers_list.append(i) code_dict = {} for j in range(0, num_rounds + 1): chars_list = list(string.ascii_uppercase) random.shuffle(chars_list) code_dict[j] = chars_list words_dict = {} chiffre_dict = {} for j in range(0, num_rounds + 1): word = '' chiffre = '' for i in range(0, num_letters): k = random.randint(0, 25) word = word + code_dict[j][k] if i == 0: # to prevent a leading space in the string chiffre = chiffre + str(k + 1) else: chiffre = chiffre + ' ' + str(k + 1) words_dict[j] = word chiffre_dict[j] = chiffre class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): Melessa_ID = models.StringField() num_tasks = models.IntegerField() consent = models.BooleanField(initial=True) def still_to_solve(player): # if player.session.config['stage_1'] == 1: return Constants.num_training_rounds - (player.round_number - 1) #elif player.session.config['stage_1'] == 0: # return player.num_tasks - (player.round_number - 1) ########################################################################################################### ################################## FOR THE REAL EFFORT TASK ################################ ########################################################################################################### ########################################################################################################### ################################## PAGES ################################ ########################################################################################################### class ExplanationTask(Page): def is_displayed(player): return player.round_number == 1 @staticmethod def vars_for_template(player: Player): return { 'num_letters': Constants.num_letters, 'number_words': Constants.num_training_rounds, 'number_string': Constants.chiffre_dict[0], 'solution': Constants.words_dict[0], 'display_numbers': Constants.numbers_list, 'display_chars': Constants.code_dict[0], 'words_dict': Constants.words_dict, 'chiffre_dict': Constants.chiffre_dict, } class EnterSolution(Page): # template_name = 'transcription_task/EnterSolution.html' def is_displayed(player): # if player.session.config['stage_1'] == 1: return player.round_number <= Constants.num_training_rounds # elif player.session.config['stage_1'] == 0: # return player.round_number <= player.num_tasks @staticmethod def vars_for_template(player: Player): return { 'number_string': Constants.chiffre_dict[player.round_number], 'solution': Constants.words_dict[player.round_number], 'display_numbers': Constants.numbers_list, 'display_chars': Constants.code_dict[player.round_number], 'solved_words': player.round_number - 1, 'still_to_solve': player.still_to_solve(), 'words_dict': Constants.words_dict, 'chiffre_dict': Constants.chiffre_dict, } @staticmethod def before_next_page(player, timeout_happened): return { 'solved_words': player.round_number, } # @staticmethod # def error_message(player: Player, values): # if values['solution']!= Constants.words_dict[player.round_number]: # return 'There is an error in your transcription. Please check again.' class Part1(Page): def is_displayed(player): return player.round_number == 1 page_sequence = [#Consent, #GeneralInstructions, #Part1, ExplanationTask, EnterSolution, ]