OperatorPage#
- class alfred3.admin.OperatorPage(title: Optional[str] = None, name: Optional[str] = None, fixed_width: Optional[str] = None, responsive_width: Optional[str] = None, header_color: Optional[str] = None, background_color: Optional[str] = None, footer_text: Optional[str] = None, *args, **kwargs)[source]#
Bases:
alfred3.admin.AdminPage
Base class for admin pages with operator access.
- Parameters
**kwargs –
Inherited keyword arguments
background_color (str)
A color to be used for the background of this page. Can be any color value understood by CSS, including hex and RGB. Can be defined as a class attribute.
fixed_width (str)
Custom value for defining a fixed width of the page. Only takes effect, if the experiment is set to generally operate with a fixed page width in config.conf (option responsive in section layout must be false). Must be a string including a unit, e.g. 900px. Can be defined as a class attribute.
footer_text (str)
Page-specific footer text. Replaces the
footer_text
defined inconfig.conf
. Can be defined as a class attribute.header_color (str)
A color to be used for the header of this page. Can be any color value understood by CSS, including hex and RGB. Can be defined as a class attribute.
minimum_display_time (str)
The minimal amount of time that the page must be displayed, before participants can move to the next page. Must be specified as a string with a unit of s (for seconds), or m (for minutes), for instance 30s. Defaults to None. Can be defined as a class attribute.
minimum_display_time_msg (str)
A page-specific message to be displayed, if participants try to move forward before the minimum display time has expired. Defaults to None, which means that the default message defined in config.conf will be used. Can be defined as a class attribute.
name (str)
Name of the member. Must be unique throughout the experiment. Can be defined as a class attribute. When you write a page or section in class style, the name can be inferred from the class name and does not need to be defined explicitly again. If a name is defined explicitly as a class attribute, that name is used.
prefix_element_names (bool)
If True, the names of all input elements on this page will be prefixed with the page name. Defaults to None. Can be defined as a class attribute.
progress (int, float)
Can be used to manually determine the level of experiment progress displayed in the experiments progress bar. Can be an int or float between 0 and 100. Defaults to None, which means that the experiment-wide setting is used (see
ExperimentSession.progress_bar
). Can be defined as a class attribute.responsive_width (str)
Custom values for definig the width of the page in percent of the screen width. Only takes effect, if the option responsive in section layout is true (which is the default). Must be a single string with 1 to 4 relative widths separated by commas, e.g. 60%, 50%. The first value refers to small (sm) screens, the following values to the next bigger ones. Extra small screens like mobile phones will always get 100% width. If the string contains less than four values, the last value will be used for all screens from that size on upward. The sizes are taken from Bootstrap and correspond to the five width attributes of a
RowLayout
. By default, responsive widths are - 100% on extra small screens (below 576px, not modifiable) - 85% on small screens (576-767px, think of tablets) - 75% on medium screens (768-991px, think of small laptops) - 65% on large screens (992-1199px) - 55% on extra large screens (1200px and larger) Can be defined as a class attribute.subtitle (str)
Subtitle of the member. Can be defined as a class attribute.
title (str)
Title of the member. Can be defined as a class attribute.
vargs (dict)
A dictionary that can be used to pass additional arguments to the page. The arguments are then available as an instance attribute. As a special feature, the instance attribute allows you to access the values of the dictionary not only via the usual square-bracket notation, but also via dot-notation. This argument fulfills a similar function as
**kwargs
do sometimes, but it makes sure that user-defined additional arguments will not collide with inherited keywords arguments. Can be defined as a class attribute.
A monitoring page has access level
AdminAccess.LEVEL1
This means that it can be accessed with the password defined by the option adminpass_lvl2 in section general of secrets.confThe base class is intended to be used for the definition of specific admin pages.
See also
The individual levels are described in
AdminAccess
. If you are uncertain about the correct level for your admin page, check this page out.Examples
A basic admin page that shows the number of datasets associated with the experiment. First we define the class, then we add it to the experiment’s admin mode. Note that the admin module has to be imported individually:
import alfred3 as al from alfred3 import admin exp = al.Experiment() @exp.member(admin=True) class MyAdminPage(admin.OperatorPage): def on_exp_access(self): n = len(self.exp.all_exp_data) self += al.Text(f"Number of data sets: {n}")
Methods
Informs the member that it was added to an experiment session.
Informs the member that it was added to a section.
Appends a variable number of elements to the page.
Closes the page.
Hook for defining a page's own movement behavior, executed every time a movement from the page takes place, before
on_first_hide()
andon_each_hide()
.Iterates over the visit durations for this page.
Returns the duration of the last visit to this page in the current session in seconds.
Returns the duration of the last visit to this page in the current session in seconds.
Executed once, when the page is closed, before data saving.
Executed every time the page is hidden, before closing it and before saving data, but after executing
on_first_hide()
.Executed every time the page is shown, after executing
on_first_show()
.Executed once, when the
ExperimentSession
becomes available to the page.Executed once, when the page is hidden for the first time, before executing
on_each_hide()
.Executed once, when the page is shown for the first time, before executing
on_each_show()
.Returns the position of this page or section inside its parent section, starting at 1.
Hook for computations for preparing a page for display.
Saves current experiment data.
Hook for controlling whether a page or section should be shown.
List of the parent section and the grandparent sections (recursive).
Returns True, if the validation checks pass, False otherwise.
Returns the subset of members in the given attribute that should be shown.
Attributes
Alias for
elements
.Alias for
input_elements
.A color to be used for the background of this page.
Returns a dict of data for all input elements on the page.
Dictionary of elements belonging to this page.
The
ExperimentSession
to which this member belongs.The
ExperimentSession
to which this member belongs.Dict of all input elements on this page with non-empty data attribute.
Custom value for defining a fixed width of the page.
Page-specific footer text.
Returns True, if the page has been displayed in the ongoing experiment session.
A color to be used for the header of this page.
Dict of all input elements on this page.
If True, the member will spawn a logger that can be configured individually for each instance
Returns True, if the page is closed.
Minimal amount of time that a page must be displayed before participants can move forward.
Message that is displayed if participants try to leave a page before the minimum display time is up.
False, if the experiment tolerates skipping this page entirely.
Unique name of the member.
Alias for
section
.Name of the parent section.
If True, the names of all elements added to this page will receive a prefix of the page's name.
Can be used to manually determine to level of experiment progress displayed in the experiment's progress bar.
The member's parent section.
Short version of
tree
, without the_root._content
part that is the same for all members.Boolean, indicating whether a page should be shown.
Page subtitle (str).
Alias for
name
, included under this name for backwards compatibility.Page title (str).
A single string, indicating the member's position in the experiment.
Alias for
name
, included under this name for backwards compatibility.Returns an empty dict for 'normal' pages and the input data for unlinked pages.
Returns a dict of all elements on the page that already have access to the experiment session.
A dictionary of additional arguments passed on the class upon initialization.