oTree Forum >

UndefinedVariable: Cannot resolve the variable 'previous_price_offer' (line 56, in "previous_price_offer")

#1 by UlkarQ

I get the error on the title while the code runs smoothly for all other pages. 
Never had a problem until added progress titles to sliders on the previous page. Could That be the source of the issue?

Here is the page:
{{ block title }}
{{ endblock }}

{% block styles %}
<style>
    body {
        background-color: lightgray;
    }

    .container {
        padding-top: 100px;
    }

    .container-x {
        border: 1px solid #000;
        padding: 10px;
        text-align: center;
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
    }

    .content {
        margin: -120px 0 20px 0;
        text-align: center;
        background-color: lightgray;
        padding: 10px 25px 10px 25px;
        text-transform: uppercase;
        border: 1px solid #000;
        width: 50%;
    }
</style>
{% endblock %}

{{ block content }}

<div class="container-x">
    <div class="content">
        <div class="title">
            <div class="row text-start">
                <div class="col-md-8 offset-md-2">
                    <h6 class="text-center"><b>Your Previous Offer:</b></h6>
                    <table class="table table-borderless">
                        <tbody>
                            <thead>
                    <tr>
                        <th></th>
                        <th>Offer</th>
                        <th>Payoff</th>
                    </tr>
                    </thead>
                        <tr>
                            <td><b>Price</b></td>
                            <td>{{ previous_price_offer }}</td>
                            <td>{{ payoff_previous_price }}</td>
                        </tr>
                        <tr>
                            <td><b>License</b></td>
                            <td>{{ previous_license_offer }}</td>
                            <td>{{ payoff_previous_licence }}</td>
                        </tr>
                        <tr>
                            <td><b>Storage</b></td>
                            <td>{{ previous_storage_offer }}</td>
                            <td>{{ payoff_previous_storage }}</td>
                        </tr>
                        <tr>
                            <td><b>Payoff</b></td>
                            <td>{{ step_payoff }}</td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-md-12">
            <h6><b>Your counterpart’s Offer:</b></h6>
        </div>
        <div class="col-md-12">
            
            <p class="text-start">
                <i>I can offer you a price of $110, 8 years of LCD and 7 GB.</i>

            </p>
        </div>
        <div class="col-md-4 text-start">
            
            <table class="table">
                <tbody>
                    <thead>
                    <tr>
                        <th></th>
                        <th>Offer</th>
                        <th>Payoff</th>
                    </tr>
                    </thead>
                <tr>
                    <td><b>Price:</b></td>
                    <td>$110</strong></td>
                    <td>10</strong></td>
                </tr>
                <tr>
                    <td><b>License:</b></td>
                    <td>8Years</strong></td>
                    <td>6</strong></td>
                </tr>
                <tr>
                    <td><b>Storage</b></td>
                    <td>7GB</strong></td>
                    <td>6</strong></td>
                </tr>
                <tr>
                    <td><b>Counterpart's Concession</b></td>
                    <td></td>
                    <td>22</strong></td>
                </tr>
                <tr>
                    <td><b>Your Total Payoff</b></td>
                    <td></td>
                    <td>22</strong></td>
                </tr>
                </tbody>
            </table>
        </div>
        <div class="col-md-12">
            <div class="row">
                <div class="col-md-12">
                    <div>
                        
                        <div class="col-md-12">
                            <div class="row">
                                <div class="col-md-3">
                                    <button name="offer_5_accept" value="True" class="btn"
                                            style="border: 2px solid black;">
                                        <b>Accept the Offer</b>
                                    </button>
                                </div>
                                <div class="col-md-3">
                                    <button name="offer_5_counteroffer" value="True" class="btn"
                                            style="border: 2px solid black;">
                                        <b>Make Counteroffer</b>
                                    </button>
                                </div>
                                <div class="col-md-3">
                                    <button name="offer_5_end_negotiation" value="True" class="btn"
                                            style="border: 2px solid black;">
                                        <b>End Negotiation</b>
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{{ endblock }}

The init.py:
from otree.api import *

doc = """
Your app description
"""


class C(BaseConstants):
    NAME_IN_URL = 'HL'
    PLAYERS_PER_GROUP = None
    NUM_ROUNDS = 1

    PRICE_CHOICES = [
        ("$150", "$150"),
        ("$145", "$145"),
        ("$140", "$140"),
        ("$135", "$135"),
        ("$130", "$130"),
        ("$125", "$125"),
        ("$120", "$120"),
        ("$115", "$115"),
        ("$110", "$110"),
        ("$105", "$105"),
        ("$100", "$100")
    ]

    LICENSE_CHOICES = [
        ("0 Years", "0 Years"),
        ("1 Year", "1 Year"),
        ("2 Years", "2 Years"),
        ("3 Years", "3 Years"),
        ("4 Years", "4 Years"),
        ("5 Years", "5 Years"),
        ("6 Years", "6 Years"),
        ("7 Years", "7 Years"),
        ("8 Years", "8 Years"),
        ("9 Years", "9 Years"),
        ("10 Years", "10 Years")
    ]

    STORAGE_CHOICES = [
        ("0 GB", "0 GB"),
        ("1 GB", "1 GB"),
        ("2 GB", "2 GB"),
        ("3 GB", "3 GB"),
        ("4 GB", "4 GB"),
        ("5 GB", "5 GB"),
        ("6 GB", "6 GB"),
        ("7 GB", "7 GB"),
        ("8 GB", "8 GB"),
        ("9 GB", "9 GB"),
        ("10 GB", "10 GB")
    ]

    

    

    PAYOFFS_DICT = {
        "price": {
            PRICE_CHOICES[0][0]: 50,
            PRICE_CHOICES[1][0]: 45,
            PRICE_CHOICES[2][0]: 40,
            PRICE_CHOICES[3][0]: 35,
            PRICE_CHOICES[4][0]: 30,
            PRICE_CHOICES[5][0]: 25,
            PRICE_CHOICES[6][0]: 20,
            PRICE_CHOICES[7][0]: 15,
            PRICE_CHOICES[8][0]: 10,
            PRICE_CHOICES[9][0]: 5,
            PRICE_CHOICES[10][0]: 0
        },
        "license": {
            LICENSE_CHOICES[0][0]: 30,
            LICENSE_CHOICES[1][0]: 27,
            LICENSE_CHOICES[2][0]: 24,
            LICENSE_CHOICES[3][0]: 21,
            LICENSE_CHOICES[4][0]: 18,
            LICENSE_CHOICES[5][0]: 15,
            LICENSE_CHOICES[6][0]: 12,
            LICENSE_CHOICES[7][0]: 9,
            LICENSE_CHOICES[8][0]: 6,
            LICENSE_CHOICES[9][0]: 3,
            LICENSE_CHOICES[10][0]: 0,
        },
        "storage": {
            STORAGE_CHOICES[0][0]: 20,
            STORAGE_CHOICES[1][0]: 18,
            STORAGE_CHOICES[2][0]: 16,
            STORAGE_CHOICES[3][0]: 14,
            STORAGE_CHOICES[4][0]: 12,
            STORAGE_CHOICES[5][0]: 10,
            STORAGE_CHOICES[6][0]: 8,
            STORAGE_CHOICES[7][0]: 6,
            STORAGE_CHOICES[8][0]: 4,
            STORAGE_CHOICES[9][0]: 2,
            STORAGE_CHOICES[10][0]: 0,
        }
    }


class Subsession(BaseSubsession):
    pass


class Group(BaseGroup):
    pass


class Player(BasePlayer):
    nickname = models.StringField(
        verbose_name=""
    )

    i_achieve1 = models.IntegerField(
        verbose_name="",
        min=0,
        max=100,
    )

    cp_achieve1 = models.IntegerField(
        verbose_name="",
        min=0,
        max=100,
    )
    i_achieve2 = models.IntegerField(
        verbose_name="",
        min=0,
        max=100,
    )

    cp_achieve2 = models.IntegerField(
        verbose_name="",
        min=0,
        max=100,
    )
    IQ1 = models.IntegerField(
        label='',
        widget=widgets.RadioSelect(),
        choices=[
            [1, '… mostly distributive with little options for trade-offs.'],
            [2, '… mostly integrative with options for trade-offs.'],
        ]
    )
    IQ2 = models.IntegerField(
        label='',
        widget=widgets.RadioSelect(),
        choices=[
            [1, '… the buyer, and a low price with high licence contract duration, and online storage is advantageous.'],
            [2, '… the seller, and a high price with low licence contract duration, and online storage is advantageous.'],
        ]
    )
    IQ3 = models.IntegerField(
        label='',
        widget=widgets.RadioSelect(),
        choices=[
            [1, 'The Hard RL is 0 payoff points.'],
            [2, 'The Hard RL is 10 payoff points.'],
            [3, 'The Hard RL is 20 payoff points.'],
        ]
    )
    IQ4 = models.IntegerField(
        label='',
        widget=widgets.RadioSelect(),
        choices=[
            [1, 'The Soft RL is 25 payoff points.'],
            [2, 'The Soft RL is 35 payoff points.'],
            [3, 'The Soft RL is 45 payoff points.'],
        ]
    )

    # ***********OFFER 0*******************

    offer_0_accept = models.BooleanField(
        blank=True,
        initial=False
    )
    offer_0_counteroffer = models.BooleanField(
        blank=True,
        initial=False
    )
    offer_0_end_negotiation = models.BooleanField(
        blank=True,
        initial=False
    )

    message_offer_0 = models.LongStringField(
        verbose_name="",
        blank=True
    )

    price_offer_0 = models.StringField(
        label='Price',
        widget=widgets.RadioSelect(),
        choices=C.PRICE_CHOICES
    )

    license_offer_0 = models.StringField(
        label='Licence',
        widget=widgets.RadioSelect(),
        choices=C.LICENSE_CHOICES
    )

    storage_offer_0 = models.StringField(
        label='Storage',
        widget=widgets.RadioSelect(),
        choices=C.STORAGE_CHOICES
    )

    # ***********OFFER 1*******************

    offer_1_accept = models.BooleanField(
        blank=True,
        initial=False
    )
    offer_1_counteroffer = models.BooleanField(
        blank=True,
        initial=False
    )
    offer_1_end_negotiation = models.BooleanField(
        blank=True,
        initial=False
    )

    message_offer_1 = models.LongStringField(
        verbose_name="",
        blank=True
    )

    price_offer_1 = models.StringField(
        verbose_name="",
        widget=widgets.RadioSelect(),
        choices=C.PRICE_CHOICES
    )

    license_offer_1 = models.StringField(
        verbose_name="",
        widget=widgets.RadioSelect(),
        choices=C.LICENSE_CHOICES
    )

    storage_offer_1 = models.StringField(
        verbose_name="",
        widget=widgets.RadioSelect(),
        choices=C.STORAGE_CHOICES
    )

    # ***********OFFER 2*******************

    offer_2_accept = models.BooleanField(
        blank=True,
        initial=False
    )
    offer_2_counteroffer = models.BooleanField(
        blank=True,
        initial=False
    )
    offer_2_end_negotiation = models.BooleanField(
        blank=True,
        initial=False
    )

    message_offer_2 = models.LongStringField(
        verbose_name="",
        blank=True
    )

    price_offer_2 = models.StringField(
        verbose_name="",
        widget=widgets.RadioSelect(),
        choices=C.PRICE_CHOICES
    )

    license_offer_2 = models.StringField(
        verbose_name="",
        widget=widgets.RadioSelect(),
        choices=C.LICENSE_CHOICES
    )

    storage_offer_2 = models.StringField(
        verbose_name="",
        widget=widgets.RadioSelect(),
        choices=C.STORAGE_CHOICES
    )

    # ***********OFFER 3*******************

    offer_3_accept = models.BooleanField(
        blank=True,
        initial=False
    )
    offer_3_counteroffer = models.BooleanField(
        blank=True,
        initial=False
    )
    offer_3_end_negotiation = models.BooleanField(
        blank=True,
        initial=False
    )

    message_offer_3 = models.LongStringField(
        verbose_name="",
        blank=True
    )

    price_offer_3 = models.StringField(
        verbose_name="",
        widget=widgets.RadioSelect(),
        choices=C.PRICE_CHOICES
    )

    license_offer_3 = models.StringField(
        verbose_name="",
        widget=widgets.RadioSelect(),
        choices=C.LICENSE_CHOICES
    )

    storage_offer_3 = models.StringField(
        verbose_name="",
        widget=widgets.RadioSelect(),
        choices=C.STORAGE_CHOICES
    )

    # ***********OFFER 4*******************

    offer_4_accept = models.BooleanField(
        blank=True,
        initial=False
    )
    offer_4_counteroffer = models.BooleanField(
        blank=True,
        initial=False
    )
    offer_4_end_negotiation = models.BooleanField(
        blank=True,
        initial=False
    )

    message_offer_4 = models.LongStringField(
        verbose_name="",
        blank=True
    )

    price_offer_4 = models.StringField(
        verbose_name="",
        widget=widgets.RadioSelect(),
        choices=C.PRICE_CHOICES
    )

    license_offer_4 = models.StringField(
        verbose_name="",
        widget=widgets.RadioSelect(),
        choices=C.LICENSE_CHOICES
    )

    storage_offer_4 = models.StringField(
        verbose_name="",
        widget=widgets.RadioSelect(),
        choices=C.STORAGE_CHOICES
    )


    
    

    own_achievement = models.IntegerField(
        verbose_name="",
        min=0,
        max=100
    )

    counterpart_achievement = models.IntegerField(
        verbose_name="",
        
        max=100
    )
    Coop_Slider=models.IntegerField(min=0)
    Fair_Slider=models.IntegerField(min=0)
    Trust_Slider=models.IntegerField(min=0)
    Weak_Slider=models.IntegerField(min=0)
    Satisfy_Slider=models.IntegerField(min=0)
    LongT_Slider=models.IntegerField(min=0)

    # ***********OFFER 5*******************

    offer_5_accept = models.BooleanField(
        blank=True,
        initial=False
    )
    offer_5_counteroffer = models.BooleanField(
        blank=True,
        initial=False
    )
    offer_5_end_negotiation = models.BooleanField(
        blank=True,
        initial=False
    )

    message_offer_5 = models.LongStringField(
        verbose_name="",
        blank=True
    )

    price_offer_5 = models.StringField(
        verbose_name="",
        widget=widgets.RadioSelect(),
        choices=C.PRICE_CHOICES
    )

    license_offer_5 = models.StringField(
        verbose_name="",
        widget=widgets.RadioSelect(),
        choices=C.LICENSE_CHOICES
    )

    storage_offer_5 = models.StringField(
        verbose_name="",
        widget=widgets.RadioSelect(),
        choices=C.STORAGE_CHOICES
    )

    # ***********OFFER 6*******************

    offer_6_accept = models.BooleanField(
        blank=True,
        initial=False
    )
    offer_6_counteroffer = models.BooleanField(
        blank=True,
        initial=False
    )
    offer_6_end_negotiation = models.BooleanField(
        blank=True,
        initial=False
    )

    message_offer_6 = models.LongStringField(
        verbose_name="",
        blank=True
    )

    price_offer_6 = models.StringField(
        verbose_name="",
        widget=widgets.RadioSelect(),
        choices=C.PRICE_CHOICES
    )

    license_offer_6 = models.StringField(
        verbose_name="",
        widget=widgets.RadioSelect(),
        choices=C.LICENSE_CHOICES
    )

    storage_offer_6 = models.StringField(
        verbose_name="",
        widget=widgets.RadioSelect(),
        choices=C.STORAGE_CHOICES
    )

    FinalMessageS = models.LongStringField(
        verbose_name="",
        blank=True
    )

    age = models.IntegerField(
        label='',
        min=18,
        max=99
    )

    sex = models.IntegerField(
        label='',
        widget=widgets.RadioSelect(),
        choices=[
            [1, 'Female'],
            [2, 'Male'],
            [3, 'Other']
        ]
    )

    discipline = models.IntegerField(
        label='',
        widget=widgets.RadioSelect(),
        choices=[
            [1, 'Social Sciences'],
            [2, 'Natural Sciences'],
            [3, 'Art, Letter and Languages'],
            [4, 'Technical Sciences'],
            [6, 'Medicine'],
            [7, 'Business'],
            [8, 'Other']
        ]
    )

    degree = models.IntegerField(
        label='',
        widget=widgets.RadioSelect(),
        choices=[
            [1, 'BA'],
            [2, 'BSc'],
            [3, 'MA'],
            [4, 'MSc'],
            [5, 'Other']
        ]
    )

    # ***************Payoff****************
    payoff_0 = models.IntegerField(initial=10)
    payoff_1 = models.IntegerField(initial=0)
    payoff_2 = models.IntegerField(initial=0)
    payoff_3 = models.IntegerField(initial=0)
    payoff_4 = models.IntegerField(initial=0)
    payoff_5 = models.IntegerField(initial=0)
    payoff_6 = models.IntegerField(initial=0)

    total_payoff = models.IntegerField()


    Coop = models.IntegerField(
    widget=widgets.RadioSelect,
    choices=[1, 2, 3, 4, 6, 6, 7]
)
    Agree = models.IntegerField(
    widget=widgets.RadioSelect,
    choices=[1, 2, 3, 4, 6, 6, 7]
)
    Compr = models.IntegerField(
    widget=widgets.RadioSelect,
    choices=[1, 2, 3, 4, 6, 6, 7]
)
    Accomm = models.IntegerField(
    widget=widgets.RadioSelect,
    choices=[1, 2, 3, 4, 6, 6, 7]
)
    Oblig = models.IntegerField(
    widget=widgets.RadioSelect,
    choices=[1, 2, 3, 4, 6, 6, 7]
)
    Fair = models.IntegerField(
    widget=widgets.RadioSelect,
    choices=[1, 2, 3, 4, 6, 6, 7]
)
    Reason = models.IntegerField(
    widget=widgets.RadioSelect,
    choices=[1, 2, 3, 4, 6, 6, 7]
)
    Just = models.IntegerField(
    widget=widgets.RadioSelect,
    choices=[1, 2, 3, 4, 6, 6, 7]
)
    Self = models.IntegerField(
    widget=widgets.RadioSelect,
    choices=[1, 2, 3, 4, 6, 6, 7]
)
    Soft = models.IntegerField(
    widget=widgets.RadioSelect,
    choices=[1, 2, 3, 4, 6, 6, 7]
)
    Weak = models.IntegerField(
    widget=widgets.RadioSelect,
    choices=[1, 2, 3, 4, 6, 6, 7]
)
    Compl = models.IntegerField(
    widget=widgets.RadioSelect,
    choices=[1, 2, 3, 4, 6, 6, 7]
)
    Yield = models.IntegerField(
    widget=widgets.RadioSelect,
    choices=[1, 2, 3, 4, 6, 6, 7]
)
    Honest = models.IntegerField(
    widget=widgets.RadioSelect,
    choices=[1, 2, 3, 4, 6, 6, 7]
)
    Real = models.IntegerField(
    widget=widgets.RadioSelect,
    choices=[1, 2, 3, 4, 6, 6, 7]
)
    Plaus = models.IntegerField(
    widget=widgets.RadioSelect,
    choices=[1, 2, 3, 4, 6, 6, 7]
)
    Sinc = models.IntegerField(
    widget=widgets.RadioSelect,
    choices=[1, 2, 3, 4, 6, 6, 7]
)

    q1 = models.IntegerField(
    widget=widgets.RadioSelect,
    choices=[1, 2, 3, 4, 6, 6, 7]
)    

    q2 = models.IntegerField(
    widget=widgets.RadioSelect,
    choices=[1, 2, 3, 4, 6, 6, 7]
)
    q3 = models.IntegerField(
    widget=widgets.RadioSelect,
    choices=[1, 2, 3, 4, 6, 6, 7]
)
    q4 = models.IntegerField(
    widget=widgets.RadioSelect,
    choices=[1, 2, 3, 4, 6, 6, 7]
)
    q5 = models.IntegerField(
    widget=widgets.RadioSelect,
    choices=[1, 2, 3, 4, 6, 6, 7]
)    
    q6 = models.IntegerField(
    widget=widgets.RadioSelect,
    choices=[1, 2, 3, 4, 6, 6, 7]
)
    q7 = models.IntegerField(
    widget=widgets.RadioSelect,
    choices=[1, 2, 3, 4, 6, 6, 7]    
)
    q8 = models.IntegerField(
    widget=widgets.RadioSelect,
    choices=[1, 2, 3, 4, 6, 6, 7]
)
    q9 = models.IntegerField(
    widget=widgets.RadioSelect,
    choices=[1, 2, 3, 4, 6, 6, 7]
)
    q10 = models.IntegerField(
    widget=widgets.RadioSelect,
    choices=[1, 2, 3, 4, 6, 6, 7]
)
    q11 = models.IntegerField(
    widget=widgets.RadioSelect,
    choices=[1, 2, 3, 4, 6, 6, 7]
)    
    q12 = models.IntegerField(
    widget=widgets.RadioSelect,
    choices=[1, 2, 3, 4, 6, 6, 7]
)    
    q13 = models.IntegerField(
    widget=widgets.RadioSelect,
    choices=[1, 2, 3, 4, 6, 6, 7]
)
    q14 = models.IntegerField(
    widget=widgets.RadioSelect,
    choices=[1, 2, 3, 4, 6, 6, 7]
)
    q15 = models.IntegerField(
    widget=widgets.RadioSelect,
    choices=[1, 2, 3, 4, 6, 6, 7]
)
    q16 = models.IntegerField(
    widget=widgets.RadioSelect,
    choices=[1, 2, 3, 4, 6, 6, 7]
)
      


# PAGES


class Intro(Page):
    pass


class Nickname(Page):
    form_model = 'player'
    form_fields = ["nickname"]


class Expectations(Page):
    form_model = 'player'
    form_fields = ["i_achieve1", "cp_achieve1"]

class InitialQuest(Page):
    form_model = 'player'
    form_fields = ['IQ1', 'IQ2', 'IQ3', 'IQ4']    

    @staticmethod
    def error_message(player: Player, values):
        solutions = dict(IQ1=1, IQ2=2,IQ3=2,IQ4=2)
        if values != solutions:
            return "One or more answers were incorrect."


class WhoStartsFirst(Page):
    timeout_seconds = 5
class WhoStartsFirstWaiting(Page):
    timeout_seconds = 5

class Step0OpeningOC(Page):
    form_model = 'player'
    form_fields = ["offer_0_accept",
                   "offer_0_counteroffer",
                   "offer_0_end_negotiation"]


class Step0CounterOS(Page):
    form_model = 'player'
    form_fields = ['message_offer_0',
                   'price_offer_0',
                   'license_offer_0',
                   'storage_offer_0']

    @staticmethod
    def is_displayed(player: Player):
        return player.offer_0_counteroffer


class WaitingScreen1(Page):
    timeout_seconds = 5

    @staticmethod
    def is_displayed(player: Player):
        return player.offer_0_counteroffer


class Step1COC(Page):
    form_model = 'player'
    form_fields = ["offer_1_accept",
                   "offer_1_counteroffer",
                   "offer_1_end_negotiation"]

    @staticmethod
    def is_displayed(player: Player):
        return player.offer_0_counteroffer

    @staticmethod
    def vars_for_template(player: Player):
        previous_price_offer = player.price_offer_0
        previous_license_offer = player.license_offer_0
        previous_storage_offer = player.storage_offer_0

        payoff_previous_price = C.PAYOFFS_DICT["price"].get(previous_price_offer, None)
        payoff_previous_licence = C.PAYOFFS_DICT["license"].get(previous_license_offer, None)
        payoff_previous_storage = C.PAYOFFS_DICT["storage"].get(previous_storage_offer, None)

        payoff_0 = payoff_previous_price + payoff_previous_licence + payoff_previous_storage
        player.payoff_0 = payoff_0

        return dict(
            previous_price_offer=previous_price_offer,
            previous_license_offer=previous_license_offer,
            previous_storage_offer=previous_storage_offer,
            payoff_previous_price=payoff_previous_price,
            payoff_previous_licence=payoff_previous_licence,
            payoff_previous_storage=payoff_previous_storage,
            step_payoff=payoff_0
        )


class Step1COS(Page):
    form_model = 'player'
    form_fields = ['message_offer_1',
                   'price_offer_1',
                   'license_offer_1',
                   'storage_offer_1']

    @staticmethod
    def is_displayed(player: Player):
        return player.offer_1_counteroffer


class WaitingScreen2(Page):
    timeout_seconds = 5

    @staticmethod
    def is_displayed(player: Player):
        return player.offer_1_counteroffer


class Step2COC(Page):
    form_model = 'player'
    form_fields = ["offer_2_accept",
                   "offer_2_counteroffer",
                   "offer_2_end_negotiation"]

    @staticmethod
    def is_displayed(player: Player):
        return player.offer_1_counteroffer

    @staticmethod
    def vars_for_template(player: Player):
        previous_price_offer = player.price_offer_1
        previous_license_offer = player.license_offer_1
        previous_storage_offer = player.storage_offer_1

        payoff_previous_price = C.PAYOFFS_DICT["price"].get(previous_price_offer, None)
        payoff_previous_licence = C.PAYOFFS_DICT["license"].get(previous_license_offer, None)
        payoff_previous_storage = C.PAYOFFS_DICT["storage"].get(previous_storage_offer, None)

        payoff_1 = payoff_previous_price + payoff_previous_licence + payoff_previous_storage
        player.payoff_1 = payoff_1

        return dict(
            previous_price_offer=previous_price_offer,
            previous_license_offer=previous_license_offer,
            previous_storage_offer=previous_storage_offer,
            payoff_previous_price=payoff_previous_price,
            payoff_previous_licence=payoff_previous_licence,
            payoff_previous_storage=payoff_previous_storage,
            step_payoff=payoff_1
        )


class Step2COS(Page):
    form_model = 'player'
    form_fields = ['message_offer_2',
                   'price_offer_2',
                   'license_offer_2',
                   'storage_offer_2']

    @staticmethod
    def is_displayed(player: Player):
        return player.offer_2_counteroffer


class WaitingScreen3(Page):
    timeout_seconds = 5

    @staticmethod
    def is_displayed(player: Player):
        return player.offer_2_counteroffer


class Step3COC(Page):
    form_model = 'player'
    form_fields = ["offer_3_accept",
                   "offer_3_counteroffer",
                   "offer_3_end_negotiation"]

    @staticmethod
    def is_displayed(player: Player):
        return player.offer_2_counteroffer

    @staticmethod
    def vars_for_template(player: Player):
        previous_price_offer = player.price_offer_2
        previous_license_offer = player.license_offer_2
        previous_storage_offer = player.storage_offer_2

        payoff_previous_price = C.PAYOFFS_DICT["price"].get(previous_price_offer, None)
        payoff_previous_licence = C.PAYOFFS_DICT["license"].get(previous_license_offer, None)
        payoff_previous_storage = C.PAYOFFS_DICT["storage"].get(previous_storage_offer, None)

        payoff_2 = payoff_previous_price + payoff_previous_licence + payoff_previous_storage
        player.payoff_2 = payoff_2

        return dict(
            previous_price_offer=previous_price_offer,
            previous_license_offer=previous_license_offer,
            previous_storage_offer=previous_storage_offer,
            payoff_previous_price=payoff_previous_price,
            payoff_previous_licence=payoff_previous_licence,
            payoff_previous_storage=payoff_previous_storage,
            step_payoff=payoff_2
        )


class Step3COS(Page):
    form_model = 'player'
    form_fields = ['message_offer_3',
                   'price_offer_3',
                   'license_offer_3',
                   'storage_offer_3']

    @staticmethod
    def is_displayed(player: Player):
        return player.offer_3_counteroffer


class WaitingScreen4(Page):
    timeout_seconds = 5

    @staticmethod
    def is_displayed(player: Player):
        return player.offer_3_counteroffer


class Step4COC(Page):
    form_model = 'player'
    form_fields = ["offer_4_accept",
                   "offer_4_counteroffer",
                   "offer_4_end_negotiation"]

    @staticmethod
    def is_displayed(player: Player):
        return player.offer_3_counteroffer

    @staticmethod
    def vars_for_template(player: Player):
        previous_price_offer = player.price_offer_3
        previous_license_offer = player.license_offer_3
        previous_storage_offer = player.storage_offer_3

        payoff_previous_price = C.PAYOFFS_DICT["price"].get(previous_price_offer, None)
        payoff_previous_licence = C.PAYOFFS_DICT["license"].get(previous_license_offer, None)
        payoff_previous_storage = C.PAYOFFS_DICT["storage"].get(previous_storage_offer, None)

        payoff_3 = payoff_previous_price + payoff_previous_licence + payoff_previous_storage
        player.payoff_3 = payoff_3

        return dict(
            previous_price_offer=previous_price_offer,
            previous_license_offer=previous_license_offer,
            previous_storage_offer=previous_storage_offer,
            payoff_previous_price=payoff_previous_price,
            payoff_previous_licence=payoff_previous_licence,
            payoff_previous_storage=payoff_previous_storage,
            step_payoff=payoff_3
        )


class Step4COS(Page):
    form_model = 'player'
    form_fields = ['message_offer_4',
                   'price_offer_4',
                   'license_offer_4',
                   'storage_offer_4']

    @staticmethod
    def is_displayed(player: Player):
        return player.offer_4_counteroffer


class Step4_Question1(Page):
    form_model = 'player'
    form_fields = ["Coop_Slider","Fair_Slider","Trust_Slider","Weak_Slider"]
    @staticmethod
    def is_displayed(player: Player):
        return player.offer_4_counteroffer

    @staticmethod
    def vars_for_template(player: Player):
        previous_price_offer = player.price_offer_4
        previous_license_offer = player.license_offer_4
        previous_storage_offer = player.storage_offer_4

        payoff_previous_price = C.PAYOFFS_DICT["price"].get(previous_price_offer, None)
        payoff_previous_licence = C.PAYOFFS_DICT["license"].get(previous_license_offer, None)
        payoff_previous_storage = C.PAYOFFS_DICT["storage"].get(previous_storage_offer, None)

        payoff_4 = payoff_previous_price + payoff_previous_licence + payoff_previous_storage
        player.payoff_4 = payoff_4

        return dict(
            previous_price_offer=previous_price_offer,
            previous_license_offer=previous_license_offer,
            previous_storage_offer=previous_storage_offer,
            payoff_previous_price=payoff_previous_price,
            payoff_previous_licence=payoff_previous_licence,
            payoff_previous_storage=payoff_previous_storage,
            step_payoff=payoff_4
        )


class Step4_Question2(Page):
    form_model = 'player'
    form_fields = ["Satisfy_Slider", "LongT_Slider"]

    @staticmethod
    def is_displayed(player: Player):
        return player.offer_4_counteroffer

    @staticmethod
    def vars_for_template(player: Player):
        previous_price_offer = player.price_offer_4
        previous_license_offer = player.license_offer_4
        previous_storage_offer = player.storage_offer_4

        payoff_previous_price = C.PAYOFFS_DICT["price"].get(previous_price_offer, None)
        payoff_previous_licence = C.PAYOFFS_DICT["license"].get(previous_license_offer, None)
        payoff_previous_storage = C.PAYOFFS_DICT["storage"].get(previous_storage_offer, None)

        payoff_4 = player.payoff_4

        return dict(
            previous_price_offer=previous_price_offer,
            previous_license_offer=previous_license_offer,
            previous_storage_offer=previous_storage_offer,
            payoff_previous_price=payoff_previous_price,
            payoff_previous_licence=payoff_previous_licence,
            payoff_previous_storage=payoff_previous_storage,
            step_payoff=payoff_4
        )


class Step4_Question3(Page):
    form_model = 'player'
    form_fields = ["i_achieve2","cp_achieve2"]

    @staticmethod
    def is_displayed(player: Player):
        return player.offer_4_counteroffer

    @staticmethod
    def vars_for_template(player: Player):
        previous_price_offer = player.price_offer_4
        previous_license_offer = player.license_offer_4
        previous_storage_offer = player.storage_offer_4

        payoff_previous_price = C.PAYOFFS_DICT["price"].get(previous_price_offer, None)
        payoff_previous_licence = C.PAYOFFS_DICT["license"].get(previous_license_offer, None)
        payoff_previous_storage = C.PAYOFFS_DICT["storage"].get(previous_storage_offer, None)

        payoff_4 = player.payoff_4

        return dict(
            previous_price_offer=previous_price_offer,
            previous_license_offer=previous_license_offer,
            previous_storage_offer=previous_storage_offer,
            payoff_previous_price=payoff_previous_price,
            payoff_previous_licence=payoff_previous_licence,
            payoff_previous_storage=payoff_previous_storage,
            step_payoff=payoff_4
        )


class Step5COC(Page):
    form_model = 'player'
    form_fields = ["offer_5_accept",
                   "offer_5_counteroffer",
                   "offer_5_end_negotiation"]

    @staticmethod
    def is_displayed(player: Player):
        return player.offer_4_counteroffer

    @staticmethod
    def vars_for_template(player: Player):
        previous_price_offer = player.price_offer_4
        previous_license_offer = player.license_offer_4
        previous_storage_offer = player.storage_offer_4

        payoff_previous_price = C.PAYOFFS_DICT["price"].get(previous_price_offer, None)
        payoff_previous_licence = C.PAYOFFS_DICT["license"].get(previous_license_offer, None)
        payoff_previous_storage = C.PAYOFFS_DICT["storage"].get(previous_storage_offer, None)

        payoff_4 = player.payoff_4

        return dict(
            previous_price_offer=previous_price_offer,
            previous_license_offer=previous_license_offer,
            previous_storage_offer=previous_storage_offer,
            payoff_previous_price=payoff_previous_price,
            payoff_previous_licence=payoff_previous_licence,
            payoff_previous_storage=payoff_previous_storage,
            step_payoff=payoff_4
        )


class Step5COS(Page):
    form_model = 'player'
    form_fields = ['message_offer_5',
                   'price_offer_5',
                   'license_offer_5',
                   'storage_offer_5']

    @staticmethod
    def is_displayed(player: Player):
        return player.offer_5_counteroffer


class WaitingScreen6(Page):
    timeout_seconds = 5

    @staticmethod
    def is_displayed(player: Player):
        return player.offer_5_counteroffer


class Step6COC(Page):
    form_model = 'player'
    form_fields = ["offer_6_accept",
                   "offer_6_counteroffer",
                   "offer_6_end_negotiation"]

    @staticmethod
    def is_displayed(player: Player):
        return player.offer_5_counteroffer

    @staticmethod
    def vars_for_template(player: Player):
        previous_price_offer = player.price_offer_5
        previous_license_offer = player.license_offer_5
        previous_storage_offer = player.storage_offer_5

        payoff_previous_price = C.PAYOFFS_DICT["price"].get(previous_price_offer, None)
        payoff_previous_licence = C.PAYOFFS_DICT["license"].get(previous_license_offer, None)
        payoff_previous_storage = C.PAYOFFS_DICT["storage"].get(previous_storage_offer, None)

        payoff_5 = payoff_previous_price + payoff_previous_licence + payoff_previous_storage
        player.payoff_5 = payoff_5

        return dict(
            previous_price_offer=previous_price_offer,
            previous_license_offer=previous_license_offer,
            previous_storage_offer=previous_storage_offer,
            payoff_previous_price=payoff_previous_price,
            payoff_previous_licence=payoff_previous_licence,
            payoff_previous_storage=payoff_previous_storage,
            step_payoff=payoff_5
        )


class Step6COS(Page):
    form_model = 'player'
    form_fields = ['message_offer_6',
                   'price_offer_6',
                   'license_offer_6',
                   'storage_offer_6']

    @staticmethod
    def is_displayed(player: Player):
        return player.offer_6_counteroffer


class FinalMessageC(Page):
    @staticmethod
    def is_displayed(player: Player):
        return player.offer_6_counteroffer

    @staticmethod
    def vars_for_template(player: Player):
        previous_price_offer = player.price_offer_6
        previous_license_offer = player.license_offer_6
        previous_storage_offer = player.storage_offer_6

        payoff_previous_price = C.PAYOFFS_DICT["price"].get(previous_price_offer, None)
        payoff_previous_licence = C.PAYOFFS_DICT["license"].get(previous_license_offer, None)
        payoff_previous_storage = C.PAYOFFS_DICT["storage"].get(previous_storage_offer, None)

        payoff_6 = payoff_previous_price + payoff_previous_licence + payoff_previous_storage
        player.payoff_6 = payoff_6

        return dict(
            previous_price_offer=previous_price_offer,
            previous_license_offer=previous_license_offer,
            previous_storage_offer=previous_storage_offer,
            payoff_previous_price=payoff_previous_price,
            payoff_previous_licence=payoff_previous_licence,
            payoff_previous_storage=payoff_previous_storage,
            step_payoff=payoff_6
        )


class FinalMessageS(Page):
    form_model = 'player'
    form_fields = ["FinalMessageS"]

    @staticmethod
    def is_displayed(player: Player):
        return player.offer_0_accept or player.offer_0_end_negotiation or \
               player.offer_1_accept or player.offer_1_end_negotiation or \
               player.offer_2_accept or player.offer_2_end_negotiation or \
               player.offer_3_accept or player.offer_3_end_negotiation or \
               player.offer_4_accept or player.offer_4_end_negotiation or \
               player.offer_5_accept or player.offer_5_end_negotiation


class FinalQuestIntro(Page):

    @staticmethod
    def is_displayed(player: Player):
        return player.offer_0_accept or player.offer_0_end_negotiation or \
               player.offer_1_accept or player.offer_1_end_negotiation or \
               player.offer_2_accept or player.offer_2_end_negotiation or \
               player.offer_3_accept or player.offer_3_end_negotiation or \
               player.offer_4_accept or player.offer_4_end_negotiation or \
               player.offer_5_accept or player.offer_5_end_negotiation or \
               player.offer_6_counteroffer


class FinalQuest(Page):
    form_model = 'player'
    form_fields = ['Coop','Agree','Compr','Accomm','Oblig','Fair','Reason','Just','Self','Soft','Weak','Compl','Yield','Honest','Real','Plaus','Sinc']
    


    @staticmethod
    def is_displayed(player: Player):
        return player.offer_0_accept or player.offer_0_end_negotiation or \
               player.offer_1_accept or player.offer_1_end_negotiation or \
               player.offer_2_accept or player.offer_2_end_negotiation or \
               player.offer_3_accept or player.offer_3_end_negotiation or \
               player.offer_4_accept or player.offer_4_end_negotiation or \
               player.offer_5_accept or player.offer_5_end_negotiation or \
               player.offer_6_counteroffer

    @staticmethod
    def before_next_page(player: Player, timeout_happened):
        player.total_payoff = player.payoff_0 + \
                              player.payoff_1 + \
                              player.payoff_2 + \
                              player.payoff_3 + \
                              player.payoff_4 + \
                              player.payoff_5 + \
                              player.payoff_6

class FinalQuest2(Page):
    form_model = 'player'
    form_fields = ['q1','q2','q3','q4','q5','q6','q7','q8','q9','q10','q11','q12',
    'q13','q14','q15','q16']
    
class ThankYou(Page):

    @staticmethod
    def is_displayed(player: Player):
        return player.offer_0_accept or player.offer_0_end_negotiation or \
               player.offer_1_accept or player.offer_1_end_negotiation or \
               player.offer_2_accept or player.offer_2_end_negotiation or \
               player.offer_3_accept or player.offer_3_end_negotiation or \
               player.offer_4_accept or player.offer_4_end_negotiation or \
               player.offer_5_accept or player.offer_5_end_negotiation or \
               player.offer_6_counteroffer


page_sequence = [
    Intro,
    Nickname,
    Expectations,
    InitialQuest,
    WhoStartsFirstWaiting,
    WhoStartsFirst,
    Step0OpeningOC,
    Step0CounterOS,
    WaitingScreen1,
    Step1COC,
    Step1COS,
    WaitingScreen2,
    Step2COC,
    Step2COS,
    WaitingScreen3,
    Step3COC,
    Step3COS,
    WaitingScreen4,
    Step4COC,
    Step4COS,
    Step4_Question1,
    Step4_Question2,
    Step4_Question3,
    Step5COC,
    Step5COS,
    WaitingScreen6,
    Step6COC,
    Step6COS,
    FinalMessageC,
    FinalMessageS,
    FinalQuestIntro,
    FinalQuest,
    FinalQuest2,
    ThankYou
]

#2 by ccrabbe

Hi UlkarQ -

This error happens when you try to use a template variable that the software can't find defined anywhere.  From the screenshot, I can see that the error comes from Step5COS.html.  Looking at your Step5COS Page class, you have no vars_for_template function.  This is the source of your error.  If you  include previous_price_offer in your vars_for_template function, this error will go away.

Thanks,
--Chris

#3 by UlkarQ

Thank you very much, Chris!!

Best Regards,
Ulkar

Write a reply

Set forum username