from otree.api import * DEBUG = True ### todo: Set to False for real experiment & controlstages working / True doc = """ Read quiz questions from a CSV (simple version). See also the 'complex' version of this app. """ def read_csv(): import csv f = open('btae/data/test_hard.csv', encoding='utf-8-sig') #adjust csv File for easy treatment rows = list(csv.DictReader(f)) return rows class C(BaseConstants): NAME_IN_URL = 'btae' PLAYERS_PER_GROUP = None QUESTIONS = read_csv() NUM_ROUNDS = len(QUESTIONS) TREATMENT = 1 ###Set between 1 and 4 (1: replicate-hard, 2: replicate-easy, 3: adapt-hard, adapt-easy) TREATMENT_ADAPT = "btae/Treatment_Adapt.html" TREATMENT_REPLIC = "btae/Treatment_Replic.html" class Subsession(BaseSubsession): pass def creating_session(subsession: Subsession): current_question = C.QUESTIONS[subsession.round_number - 1] for p in subsession.get_players(): p.question = current_question['question'] p.optionA = current_question['optionA'] p.optionB = current_question['optionB'] p.optionC = current_question['optionC'] p.optionD = current_question['optionD'] p.optionE = current_question['optionE'] p.optionF = current_question['optionF'] p.optionG = current_question['optionG'] p.solution = current_question['solution'] p.participant.quiz_num_correct = 0 class Group(BaseGroup): pass class Player(BasePlayer): introduction_control1 = models.IntegerField( label="Was ist Ihre Aufgabe im Experiment?", choices=[ [1, "..."], [2, "..."], [3, "..."] ], widget=widgets.RadioSelect, #initial=1 # TODO: herausnehmen wenn keine vorauswahl gewünscht ist, nur damit schneller geklickt werden kann ) introduction_control2 = models.IntegerField( label="Welche Auszahlung erhalten Sie, wenn Sie als Gewinner:in ausgelost werden?", choices=[ [1, "..."], [2, "..."], [3, "..."] ], widget=widgets.RadioSelect, ) introduction_control3 = models.IntegerField( label="Welche Zahl bringt Ihnen die höhsten Gewinnbetrag? ", choices=[ [1, "1"], [2, "3"], [3, "6"] ], widget=widgets.RadioSelect, ) introduction_control4 = models.IntegerField( label="Was passiert, falls Sie geprüft werden?", choices=[ [1, ""], [2, "Sie erhalten lediglich die Show-up Fee."], [3, ""] ], widget=widgets.RadioSelect, ) introduction_control5 = models.IntegerField( label="Wie bestimmt sich die Toleranz?", choices=[ [1, ""], [2, ""], [3, ""] ], widget=widgets.RadioSelect, ) introduction_control6 = models.IntegerField( label="Was passiert, wenn Ihre tatsächlich gezogene Zahl nicht im Intervall zwischen der berichteten und der Toleranzzahl liegt", choices=[ [1, ""], [2, "Sie erhalten lediglich die Show-up Fee."], [3, ""] ], widget=widgets.RadioSelect, ) vote = models.IntegerField( label="", choices=[ [1, "Test"], [2, "Lotterie"], ], widget=widgets.RadioSelect, ) prediction_own = models.IntegerField( label=" Text ", min=0, max=20, ) prediction_group = models.IntegerField( label=" Text ", min=0, max=20, ) sure = models.IntegerField( label="How sure are you to have made the right decision in the vote?", choices=[ [1, "Very unsure"], [2, ""], [3, ""], [4, ""], [5, ""], [6, ""], [7, "Very sure"] ], widget=widgets.RadioSelect, ) difficult_change = models.IntegerField( label="How difficult would you find it to change your decision?", choices=[ [1, "Very easy"], [2, ""], [3, ""], [4, ""], [5, ""], [6, ""], [7, "Very difficult"] ], widget=widgets.RadioSelect, ) important = models.IntegerField( label="How important is doing well in the test to you?", choices=[ [1, "Very unimportant"], [2, ""], [3, ""], [4, ""], [5, ""], [6, ""], [7, "Very important"] ], widget=widgets.RadioSelect, ) expected_performance = models.IntegerField( label="How good do you think you will be in the test?", choices=[ [1, "Very unimportant"], [2, ""], [3, ""], [4, ""], [5, ""], [6, ""], [7, "Very important"] ], widget=widgets.RadioSelect, ) word1 = models.BooleanField(blank=True, initial=False, choices=[ [1, "Ja"],[2, "Nein"]]) word2 = models.BooleanField(blank=True, initial=False, choices=[ [1, "Ja"],[2, "Nein"]]) word3 = models.BooleanField(blank=True, initial=False, choices=[ [1, "Ja"],[2, "Nein"]]) word4 = models.BooleanField(blank=True, initial=False, choices=[ [1, "Ja"],[2, "Nein"]]) word5 = models.BooleanField(blank=True, initial=False, choices=[ [1, "Ja"],[2, "Nein"]]) word6 = models.BooleanField(blank=True, initial=False, choices=[ [1, "Ja"],[2, "Nein"]]) word7 = models.BooleanField(blank=True, initial=False, choices=[ [1, "Ja"],[2, "Nein"]]) word8 = models.BooleanField(blank=True, initial=False, choices=[ [1, "Ja"],[2, "Nein"]]) word9 = models.BooleanField(blank=True, initial=False, choices=[ [1, "Ja"],[2, "Nein"]]) word10 = models.BooleanField(blank=True, initial=False, choices=[ [1, "Ja"],[2, "Nein"]]) word11 = models.BooleanField(blank=True, initial=False, choices=[ [1, "Ja"],[2, "Nein"]]) word12 = models.BooleanField(blank=True, initial=False, choices=[ [1, "Ja"],[2, "Nein"]]) word13 = models.BooleanField(blank=True, initial=False, choices=[ [1, "Ja"],[2, "Nein"]]) word14 = models.BooleanField(blank=True, initial=False, choices=[ [1, "Ja"],[2, "Nein"]]) word15 = models.BooleanField(blank=True, initial=False, choices=[ [1, "Ja"],[2, "Nein"]]) word16 = models.BooleanField(blank=True, initial=False, choices=[ [1, "Ja"],[2, "Nein"]]) word17 = models.BooleanField(blank=True, initial=False, choices=[ [1, "Ja"],[2, "Nein"]]) word18 = models.BooleanField(blank=True, initial=False, choices=[ [1, "Ja"],[2, "Nein"]]) word19 = models.BooleanField(blank=True, initial=False, choices=[ [1, "Ja"],[2, "Nein"]]) word20 = models.BooleanField(blank=True, initial=False, choices=[ [1, "Ja"],[2, "Nein"]]) actual_own = models.IntegerField( label=" Text ", min=0, max=20, ) estimated_group = models.IntegerField( label=" Text ", min=0, max=20, ) satisfied = models.IntegerField( label="How satisfied are you with your result in the test?", choices=[ [1, "Very unsatisfied"], [2, ""], [3, ""], [4, ""], [5, ""], [6, ""], [7, "Very satisfied"] ], widget=widgets.RadioSelect, ) sure_post = models.IntegerField( label="How sure are you now to have made the right decision in the vote?", choices=[ [1, "Very unsure"], [2, ""], [3, ""], [4, ""], [5, ""], [6, ""], [7, "Very sure"] ], widget=widgets.RadioSelect, ) difficult_change_post = models.IntegerField( label="How difficult would you find it now to change your decision in the vote?", choices=[ [1, "Very easy"], [2, ""], [3, ""], [4, ""], [5, ""], [6, ""], [7, "Very difficult"] ], widget=widgets.RadioSelect, ) difficulty = models.IntegerField( label="How difficult do you think the test was?", choices=[ [1, "Very easy"], [2, ""], [3, ""], [4, ""], [5, ""], [6, ""], [7, "Very difficult"] ], widget=widgets.RadioSelect, ) age = models.IntegerField( label="Wie alt sind Sie?", ) gender = models.IntegerField( label="Welchem Geschlecht fühlen Sie sich zugehörig?", choices=[ [1, "weiblich"], [2, "männlich"], [3, "nicht-binär"] ], widget=widgets.RadioSelect, ) major = models.StringField( label="Bitte geben Sie Ihren aktuellen Studiengang / Beruf an.", ) incom1 = models.IntegerField( label="I always pay a lot of attention to how I do things compared with how others do things.", choices=[ [1, "Ich lehne stark ab"], [2, "Ich lehne ab"], [3, "Weder noch"], [4, "Ich stimme zu"], [5, "Ich stimme stark zu"], ], widget=widgets.RadioSelect, ) incom2 = models.IntegerField( label="I often compare how I am doing socially (e.g., social skills, popularity) with other people.", choices=[ [1, "Ich lehne stark ab"], [2, "Ich lehne ab"], [3, "Weder noch"], [4, "Ich stimme zu"], [5, "Ich stimme stark zu"], ], widget=widgets.RadioSelect, ) incom3 = models.IntegerField( label="I am not the type of person who compares often with others.", choices=[ [1, "Ich lehne stark ab"], [2, "Ich lehne ab"], [3, "Weder noch"], [4, "Ich stimme zu"], [5, "Ich stimme stark zu"], ], widget=widgets.RadioSelect, ) incom4 = models.IntegerField( label="I often try to find out what others think who face similar problems as I face.", choices=[ [1, "Ich lehne stark ab"], [2, "Ich lehne ab"], [3, "Weder noch"], [4, "Ich stimme zu"], [5, "Ich stimme stark zu"], ], widget=widgets.RadioSelect, ) incom5 = models.IntegerField( label="Ich möchte immer wissen, was andere in einer ähnlichen Situation tun würden.", choices=[ [1, "Ich lehne stark ab"], [2, "Ich lehne ab"], [3, "Weder noch"], [4, "Ich stimme zu"], [5, "Ich stimme stark zu"], ], widget=widgets.RadioSelect, ) incom6 = models.IntegerField( label="Wenn ich mehr über etwas wissen möchte, versuche ich herauszufinden was andere darpber denken.", choices=[ [1, "Ich lehne stark ab"], [2, "Ich lehne ab"], [3, "Weder noch"], [4, "Ich stimme zu"], [5, "Ich stimme stark zu"], ], widget=widgets.RadioSelect, ) attention1 = models.IntegerField( label="Ich lese die Fragen aufmerksam und wähle deshalb 'Weder noch' aus.", choices=[ [1, "Ich lehne stark ab"], [2, "Ich lehne ab"], [3, "Weder noch"], [4, "Ich stimme zu"], [5, "Ich stimme stark zu"], ], widget=widgets.RadioSelect, ) risk = models.IntegerField( label="Wie bereits sind Sie, im Allgemeinen, Risiken einzugehen?", choices=[ [0, "Überhaupt nicht bereit Risiken einzugehehn"], [1, ""], [2, ""], [3, ""], [4, ""], [5, ""], [6, ""], [7, ""], [8, ""], [9, ""], [10, "Sehr bereit Risiken einzugehen"], ], widget=widgets.RadioSelectHorizontal, ) dospert1 = models.IntegerField( label="Taking some questionable deductions on your income tax return.", choices=[ [1, "Extrem unwahrscheinlich"], [2, "Ziemlich unwahrscheinlich"], [3, "Eher unwahrscheinlich"], [4, "Unklar"], [5, "Eher wahrscheinlich"], [6, "Ziemlich wahrscheinlich"], [7, "Extrem wahrscheinlich"], ], widget=widgets.RadioSelectHorizontal, ) dospert2 = models.IntegerField( label="Having an affair with a married man/woman.", choices=[ [1, "Extrem unwahrscheinlich"], [2, "Ziemlich unwahrscheinlich"], [3, "Eher unwahrscheinlich"], [4, "Unklar"], [5, "Eher wahrscheinlich"], [6, "Ziemlich wahrscheinlich"], [7, "Extrem wahrscheinlich"], ], widget=widgets.RadioSelectHorizontal, ) dospert3 = models.IntegerField( label="Passing off somebody else’s work as your own.", choices=[ [1, "Extrem unwahrscheinlich"], [2, "Ziemlich unwahrscheinlich"], [3, "Eher unwahrscheinlich"], [4, "Unklar"], [5, "Eher wahrscheinlich"], [6, "Ziemlich wahrscheinlich"], [7, "Extrem wahrscheinlich"], ], widget=widgets.RadioSelectHorizontal, ) dospert4 = models.IntegerField( label="Revealing a friend’s secret to someone else.", choices=[ [1, "Extrem unwahrscheinlich"], [2, "Ziemlich unwahrscheinlich"], [3, "Eher unwahrscheinlich"], [4, "Unklar"], [5, "Eher wahrscheinlich"], [6, "Ziemlich wahrscheinlich"], [7, "Extrem wahrscheinlich"], ], widget=widgets.RadioSelectHorizontal, ) dospert5 = models.IntegerField( label="Leaving your young children alone at home while running an errand.", choices=[ [1, "Extrem unwahrscheinlich"], [2, "Ziemlich unwahrscheinlich"], [3, "Eher unwahrscheinlich"], [4, "Unklar"], [5, "Eher wahrscheinlich"], [6, "Ziemlich wahrscheinlich"], [7, "Extrem wahrscheinlich"], ], widget=widgets.RadioSelectHorizontal, ) dospert6 = models.IntegerField( label="Not returning a wallet you found that contains $200.", choices=[ [1, "Extrem unwahrscheinlich"], [2, "Ziemlich unwahrscheinlich"], [3, "Eher unwahrscheinlich"], [4, "Unklar"], [5, "Eher wahrscheinlich"], [6, "Ziemlich wahrscheinlich"], [7, "Extrem wahrscheinlich"], ], widget=widgets.RadioSelectHorizontal, ) comment = models.LongStringField( blank=True, label="Möchten Sie uns noch etwas mitteilen? (optional)", ) question = models.StringField() optionA = models.StringField() optionB = models.StringField() optionC = models.StringField() optionD = models.StringField() optionE = models.StringField() optionF = models.StringField() optionG = models.StringField() solution = models.StringField() choice = models.StringField(widget=widgets.RadioSelect) is_correct = models.BooleanField() def choice_choices(player: Player): return [ ['A', player.optionA], ['B', player.optionB], ['C', player.optionC], ['C', player.optionC], ['D', player.optionD], ['F', player.optionF], ['G', player.optionG], ] class Welcome(Page): @staticmethod def is_displayed(player: Player): return player.round_number == 1 class Instructions(Page): @staticmethod def is_displayed(player: Player): return player.round_number == 1 class ComprehensionChecks(Page): form_model = 'player' form_fields = ['introduction_control1', 'introduction_control2', 'introduction_control3', 'introduction_control4'] @staticmethod def is_displayed(player: Player): return player.round_number == 1 @staticmethod def error_message(player, values): if not DEBUG: if values['introduction_control1'] != 1 or values['introduction_control2'] != 1 or values[ 'introduction_control3'] != 3 or values['introduction_control4'] != 2: return 'Sie haben falsch geantwortet, bitte überprüfen Sie noch einmal Ihre Antworten.' class Vote(Page): form_model = 'player' form_fields = ['vote'] @staticmethod def is_displayed(player: Player): return player.round_number == 1 @staticmethod def before_next_page(player, timeout_happened): player.payoff = player.vote class Expectations1(Page): form_model = 'player' form_fields = ['prediction_own', 'prediction_group'] @staticmethod def is_displayed(player: Player): return player.round_number == 1 class Expectations2(Page): form_model = 'player' form_fields = ['sure', 'difficult_change', 'important', 'expected_performance'] @staticmethod def is_displayed(player: Player): return player.round_number == 1 class ListOfWords(Page): form_model = 'player' form_fields = ['word1', 'word2', 'word3', 'word4', 'word5', 'word6', 'word7', 'word8', 'word9', 'word10', 'word11', 'word12', 'word13', 'word14', 'word15', 'word16', 'word17', 'word18', 'word19', 'word20'] @staticmethod def is_displayed(player: Player): return player.round_number == 1 class Test(Page): form_model = 'player' form_fields = ['choice'] @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant player.is_correct = player.choice == player.solution participant.quiz_num_correct += int(player.is_correct) class Reflection1(Page): form_model = 'player' form_fields = ['actual_own', 'estimated_group'] @staticmethod def is_displayed(player: Player): return player.round_number == C.NUM_ROUNDS class Reflection2(Page): form_model = 'player' form_fields = ['satisfied', 'sure_post', 'difficult_change_post', 'difficulty'] @staticmethod def is_displayed(player: Player): return player.round_number == C.NUM_ROUNDS class Questionnaire(Page): @staticmethod def is_displayed(player: Player): return player.round_number == C.NUM_ROUNDS class QuestionnaireINCOM(Page): form_model = 'player' form_fields = ['incom1', 'incom2', 'incom3', 'attention1', 'incom4', 'incom5', 'incom6'] @staticmethod def is_displayed(player: Player): return player.round_number == C.NUM_ROUNDS class QuestionnaireDospert(Page): form_model = 'player' form_fields = ['dospert1', 'dospert2', 'dospert3', 'dospert4', 'dospert5', 'dospert6'] @staticmethod def is_displayed(player: Player): return player.round_number == C.NUM_ROUNDS class QuestionnaireDemographics(Page): form_model = 'player' form_fields = ['age', 'gender', 'major', 'risk', 'comment'] @staticmethod def is_displayed(player: Player): return player.round_number == C.NUM_ROUNDS class FinalPage(Page): @staticmethod def is_displayed(player: Player): return player.round_number == C.NUM_ROUNDS class Results(Page): @staticmethod def is_displayed(player: Player): return player.round_number == C.NUM_ROUNDS @staticmethod def vars_for_template(player: Player): return dict(round_players=player.in_all_rounds()) page_sequence = [Welcome, Instructions, ComprehensionChecks, Vote, Expectations1, Expectations2, ListOfWords, Test, Reflection1, Reflection2, Questionnaire, QuestionnaireDospert, QuestionnaireINCOM, FinalPage, Results]