Subsession Class
Here’s an overview of all fields and functions in the Subsession class:
creating_session()
Paying Round
The
paying_round
is the round where the player’s payoff is calculated ifrandom_payoff = True
. See Random PayoffA player’s saved emission in the
paying_round
is added to thesum_saved_emission
field ifrandom_saved_emission = True
. See Random Saved Emission
Sum saved Emission
Field
The
sum_saved_emission
field is the sum of thesaved_emission
player field for all players.The sum is either calculated across the
paying_round
or across all rounds depending on the Random Saved Emission field.The field is used as an input in the Send Payment Mail function.
Excludes all players that ar seen as bots. See Bot Criteria
Function
The
set_sum_saved_emission()
function sets thesum_saved_emission
field.Checks if a player is a bot. See Bot Criteria
If a player is not a bot then the total
saved_emission
of all players is added to thesum_saved_emission
(Either across the paying round or all rounds).A player has to finish all rounds of the CET, so that the correct data is available. Therefore, this function is only called in the last round of the CET. See Experiment Page
All Players Finished
Field
all_players_finished
is a Boolean field that turnsTrue
once all players have finished the CET.
Function
set_all_players_finished()
calculates how many players in total have finished the CET (sum_finished
).If
sum_finished
= Number of participants then theall_players_finished
field turnsTrue
.This function is only called once (for each player): When the player hits the “Next” button on the Results Page.
Helpful prints
The
helpful_prints()
function prints helpful information about the current state of many player and subsession fields to the terminal.The function can be extended at will and be used for bug fixing purposes, if a new field is added.
The function is called in every round of the CET and when a player finishes the CET.
The function is only useful if the number of participants is small.
Send Payment Mail
The send_payment_mail()
function is used to automate carbon-emission certificate purchases for experiments with real-carbon externalities, such as the CET.
For more information see ACO Documentation.
Requirements
The modules requests and smtplib have to be imported at the top of the models.py file.
A valid account from an SMTP service provider is needed. The credentials of the account have to be specified at the top of the function.
Parameters
weight_to_donate
: A float value used to pass the amount of carbon emission that is saved by the experimental participants. The Sum saved Emission is used for this.
unit
: A string value that defines the unit of the saved carbon emission. The following values are accepted:["mg", "g", "kg", "t", "oz", "lbs", "st"]
experiment_name
: A string value that specifies the name of the experiment (e.g. “Carbon Emission Task”)
payment_e_mail_name
: A string that specifies the name of the person or team that receives the mail
payment_e_mail_to
: A list containing the mail addresses of all recipients . If the mail is only to be sent to one address then a single string can be passed to the function.
How it works (basic)
The
weight_to_donate
value is converted to metric tons. The conversion is based on theunit
value.The current CO2 price per ton for emission certificates is fetched from a price endpoint that is provided by Compensators.
The price of the carbon-emission certificate is calculated.
A mail is sent to all addresses within the
payment_e_mail_to
list. The mail includes the total weight of carbon-emission saved, the current price per ton for carbon-emission certificates, as well as the link to Compensators donation form with the correct price to make the carbon-emission certificate purchase. These contents can be changed at will.
When is send_payment_mail() called?
The function is called when all players have finished the CET. For an example see Results Page