oTree Forum >

OTREE_PRODUCTION and page times

#1 by WD95

Hello,

I do not want the participants to see the debug info. The documentation indicates that I need to set the OTREE_PRODUCTION variable, but I'm unsure where and how to set this variable. I need your help with this. 

Additionally, I want to record the time participants spend on a page, and the documentation also provides a Python package for this purpose. Can this package be used directly, or do I need to make some additional settings? 

Thank you very much for your assistance.

#2 by ChristianK

Hi!

If you are using Heroku, go to your App Dashboard’s “settings”, click on "Reveal Config Vars", and add or update a new key, value pair with "OTREE_PRODUCTION" and "1".
It is a little curious that this is not in the docs (at least I could not find it).

If you run a session (or demo) and afterwards navigate to "Data" in the top menu, you should find a Page Times entry at the bottom. You can download the data and process it with the script provided in the docs.

Best
Christian

#3 by BonnEconLab

OTREE_PRODUCTION is an environment variable. When using Linux you could set it, for instance, by including the line

export OTREE_PRODUCTION=1

in your .bashrc file.

You can, however, also set it locally by including 

DEBUG = 0

in your settings.py file.

#4 by BonnEconLab

Regarding the time spent on each page, I would suggest recording the times by including code like the following in your __init__.py file:

import time

class Player(BasePlayer):

    trial_onset = models.FloatField()
    trial_offset = models.FloatField()
    trial_duration = models.FloatField()

class NameOfYourPage(Page):

    @staticmethod
    def vars_for_template(player):
        player.trial_onset = time.time()

    @staticmethod
    def before_next_page(player, timeout_happened):
        player.trial_offset = time.time()
        player.trial_duration = player.trial_offset - player.trial_onset

Beware, however, that vars_for_template is executed each time anew when a participant refreshes the page. Therefore, this method is only valid if the participant does not refresh the page after.

Thus, for robustness, you might prefer to include something like

    @staticmethod
    def before_next_page(player, timeout_happened):
        player.next_page_onset = time.time()

in the class of the *previous* page.

#5 by WD95

Hello,

Thank you very much for your help. I have resolved the issues with debugging and recording the time spent on pages.

I didn't use Heroku; setting DEBUG=0 in the local settings file was a great solution. 

I found pagetimes.py in the documentation.  https://otree.readthedocs.io/en/latest/admin.html with Export Data.

Thank you once again for your assistance.

Best wishes!

Write a reply

Set forum username