oTree Forum >

New pages not displayed in the local host server

#1 by pyth_123

I had added some additional pages in pycharm but i am unable to see it in the local host. Could anyone please tell me whats wrong with my code?

My init code:
import cu as cu
from otree.api import *

doc = """
Simple trust game

class C(BaseConstants):
    NAME_IN_URL = 'trust_simple'
    NUM_ROUNDS = 1
    ENDOWMENT = cu(10)

class Subsession(BaseSubsession):

class Group(BaseGroup):
    sent_amount = models.CurrencyField(
        doc="""Amount sent by P1""",
        label="How much do you want to send to participant B?",
    sent_back_amount = models.CurrencyField(
        doc="""Amount sent back by P2""", label="How much do you want to send back?"

class Player(BasePlayer):
    name = models.StringField(label='What is your name')
    age = models.IntegerField(label='What is your age?', min=18, max=80)
    gender = models.IntegerField(choices=[
            [1, 'male'],
            [2, 'female'],
            [3, 'other']
    grade = models.StringField(label='Please rate our experiment',
                               choices=[['Good', 'Good'], ['Very Good', 'Very Good'], ['Satisfactory', 'Satisfactory'],
                                        ['Not good', 'Not Good']])

def sent_back_amount_choices(group: Group):
    return currency_range(0, group.sent_amount * C.MULTIPLIER, 1)

def set_payoffs(group: Group):
    p1 = group.get_player_by_id(1)
    p2 = group.get_player_by_id(2)
    p1.payoff = C.ENDOWMENT - group.sent_amount + group.sent_back_amount
    p2.payoff = group.sent_amount * C.MULTIPLIER - group.sent_back_amount

class Questions(Page):
    form_model = 'player'
    form_fields = ['age', 'gender', 'name']

def is_displayed(player: Player):
    return player.name, player.age, player.gender

class Send(Page):
    form_model = 'group'
    form_fields = ['sent_amount']

    def is_displayed(player: Player):
        return player.id_in_group == 1

class WaitForP1(WaitPage):

class SendBack(Page):
    form_model = 'group'
    form_fields = ['sent_back_amount']

    def is_displayed(player: Player):
        return player.id_in_group == 2

    def vars_for_template(player: Player):
        group = player.group

        return dict(tripled_amount=group.sent_amount * C.MULTIPLIER)

class ResultsWaitPage(WaitPage):
    after_all_players_arrive = set_payoffs

class Results(Page):

class Thanks(Page):

page_sequence = [Questions, Send, WaitForP1, SendBack, ResultsWaitPage, Results,GradeWaitPage, Grade,Thanks]

I am unable to see Questions page and Thanks page.

I have also added the respective html pages to the folder.

{{ block title }}Trust Game: Your Choice{{ endblock }}
{{ block content }}

    {{ include_sibling 'instructions.html' }}

        Enter your name {{Player.name}}
        Enter your age {{Player.age}}
        Please specify your gender {{Player.gender}}

    {{ formfields }}

    {{ next_button }}

{{ endblock }}


<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
Thank you for participating in the game.

PLease could someone help? I am stuck on the same experiment for two weeks.

Write a reply

Set forum username